Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-04-19 07:25:49
Exec Total Coverage
Lines: 1788 4298 41.6%
Functions: 131 350 37.4%
Branches: 957 2730 35.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include "combos.h"
67 #include <fmt/format.h>
68
69 #ifdef __EMSCRIPTEN__
70 #include "base/emscripten_utils.h"
71 #endif
72
73 extern FFScript FFCore;
74 extern bool Playing;
75 int32_t sfx_voice[WAV_COUNT];
76 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
77 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82451 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 80230 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79774 times.
✓ Branch 3 taken 81995 times.
82451 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 d[i].dp2 = get_zc_font(font_lfont_l);
254 }
255 else if(!bigfontproc)
256 {
257 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
258 }
259
260 // Make checkboxes work
261 if(d[i].proc == jwin_check_proc)
262 d[i].proc = jwin_checkfont_proc;
263 else if(d[i].proc == jwin_radio_proc)
264 d[i].proc = jwin_radiofont_proc;
265 }
266
267 jwin_center_dialog(d);
268 }
269
270
271 /**********************************/
272 /******** System functions ********/
273 /**********************************/
274
275 static char cfg_sect[] = "zeldadx"; //We need to rename this.
276 static char ctrl_sect[] = "Controls";
277 static char sfx_sect[] = "Volume";
278
279 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
280 {
281 return D_O_K;
282 }
283
284 bool is_reserved_key(int c)
285 {
286 switch(c)
287 {
288 case KEY_ESC:
289 return true;
290 }
291 return false;
292 }
293 bool is_reserved_keycombo(int c, int modflag)
294 {
295 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
296 return true;
297 return false;
298 }
299 bool checkcheat(Cheat cheat)
300 {
301 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
302 return true; //Main key pressed
303 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
304 return true; //Alt key pressed
305 return false;
306 }
307 31 void load_default_cheatkeys()
308 {
309 31 memset(cheatkeys, 0, sizeof(cheatkeys));
310 31 cheatkeys[Cheat::Life][0] = KEY_H;
311 31 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
312 31 cheatkeys[Cheat::Magic][0] = KEY_M;
313 31 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
314 31 cheatkeys[Cheat::Rupies][0] = KEY_R;
315 31 cheatkeys[Cheat::Bombs][0] = KEY_B;
316 31 cheatkeys[Cheat::Arrows][0] = KEY_A;
317 31 cheatkeys[Cheat::Clock][0] = KEY_I;
318 31 cheatkeys[Cheat::Walls][0] = KEY_F11;
319 31 cheatkeys[Cheat::Fast][0] = KEY_Q;
320 31 cheatkeys[Cheat::Light][0] = KEY_L;
321 31 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
322 31 cheatkeys[Cheat::Kill][0] = KEY_K;
323 31 cheatkeys[Cheat::GoTo][0] = KEY_G;
324 31 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
325 31 cheatkeys[Cheat::ShowL0][0] = KEY_0;
326 31 cheatkeys[Cheat::ShowL1][0] = KEY_1;
327 31 cheatkeys[Cheat::ShowL2][0] = KEY_2;
328 31 cheatkeys[Cheat::ShowL3][0] = KEY_3;
329 31 cheatkeys[Cheat::ShowL4][0] = KEY_4;
330 31 cheatkeys[Cheat::ShowL5][0] = KEY_5;
331 31 cheatkeys[Cheat::ShowL6][0] = KEY_6;
332 31 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
333 31 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
334 31 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
335 31 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
336 31 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
337 31 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
338 31 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
339 31 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
340 31 }
341 31 void load_game_configs()
342 {
343 31 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
344 31 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
345 31 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
346 31 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
347 31 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
348 31 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
349 31 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
350 31 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
351 31 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
352 31 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
353 31 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
354 31 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
355 31 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
356 31 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
357 31 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
358
359 //cheat modifier keya
360 31 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
361 31 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
362 31 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
363 31 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
364
365 //cheat keys
366 31 load_default_cheatkeys();
367 char buf[256];
368
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 31 times.
1116 for(size_t q = 1; q < Cheat::Last; ++q)
369 {
370
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 if(!bindable_cheat((Cheat)q)) continue;
371 1085 std::string cheatname = cheat_to_string((Cheat)q);
372
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 util::lowerstr(cheatname);
373 1085 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
374
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
375 1085 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
376
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
377 1085 }
378
379
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
380 joystick_index = 0;
381
382 31 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
383 31 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
384 31 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
385 31 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
386 31 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
387 31 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
388 31 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
389 31 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
390 31 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
391 31 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
392
393 31 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
394 31 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
395 31 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
396 31 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
397
398 31 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
399 31 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
400 31 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
401 31 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
402 31 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
403 31 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
404 31 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
405 31 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
406 31 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
407 31 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
408 31 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
409
410 31 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
411 31 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
412 31 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
413 31 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
414
415 31 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
416
417 31 digi_volume = zc_get_config(sfx_sect,"digi",248);
418 31 midi_volume = zc_get_config(sfx_sect,"midi",255);
419 31 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
420 31 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
421 31 pan_style = zc_get_config(sfx_sect,"pan",1);
422 // 1 <= zcmusic_bufsz <= 128
423 31 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
424 31 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
425 31 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
426 31 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
427 31 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
428 31 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
429 31 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
430 #ifdef __EMSCRIPTEN__
431 if (em_is_mobile()) NameEntryMode = 2;
432 #endif
433 31 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
434 31 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
435 31 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
436 31 title_version = zc_get_config(cfg_sect,"title",2);
437 31 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
438 31 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
439
440 //default - scale x2, 640 x 480
441 31 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
442 31 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
443 31 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
444 31 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
445 31 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
446 31 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
447 31 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
448
449 31 loadlast = zc_get_config(cfg_sect,"load_last",0);
450
451 31 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
452
453 31 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
454
455 31 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
456 31 info_opacity = zc_get_config("zc","debug_info_opacity",255);
457 #ifdef _WIN32
458 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
461 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
462
463 // This one's for Aero
464 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
465
466 // And this one fixes patches unloading on some MIDI setups
467 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
468 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
469 #else //UNIX
470 31 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
471 31 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
472 31 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
473 #endif
474 31 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
475 31 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
476
477 31 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
478
479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(strlen(qstdir)==0)
480 {
481 31 getcwd(qstdir,2048);
482 31 fix_filename_case(qstdir);
483 31 fix_filename_slashes(qstdir);
484 31 put_backslash(qstdir);
485 31 }
486 else
487 {
488 chop_path(qstdir);
489 }
490
491 31 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
492 31 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
493 31 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
494 31 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
495 31 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
496 31 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
497 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
498 31 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
499 31 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
500 31 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
501 31 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
502 31 }
503
504 void save_control_configs(bool kb)
505 {
506 if(kb)
507 {
508 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
509 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
510 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
511 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
512
513 if (!replay_is_replaying())
514 {
515 zc_set_config(ctrl_sect,"key_a",Akey);
516 zc_set_config(ctrl_sect,"key_b",Bkey);
517 zc_set_config(ctrl_sect,"key_s",Skey);
518 zc_set_config(ctrl_sect,"key_l",Lkey);
519 zc_set_config(ctrl_sect,"key_r",Rkey);
520 zc_set_config(ctrl_sect,"key_p",Pkey);
521 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
522 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
523 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
524 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
525 zc_set_config(ctrl_sect,"key_up", DUkey);
526 zc_set_config(ctrl_sect,"key_down", DDkey);
527 zc_set_config(ctrl_sect,"key_left", DLkey);
528 zc_set_config(ctrl_sect,"key_right",DRkey);
529 }
530 }
531 else
532 {
533 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
534 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
535 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
536 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
537 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
538 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
539 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
540 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
541 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
542 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
543 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
544 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
545 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
546 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
547
548 zc_set_config(ctrl_sect,"btn_a",Abtn);
549 zc_set_config(ctrl_sect,"btn_b",Bbtn);
550 zc_set_config(ctrl_sect,"btn_s",Sbtn);
551 zc_set_config(ctrl_sect,"btn_m",Mbtn);
552 zc_set_config(ctrl_sect,"btn_l",Lbtn);
553 zc_set_config(ctrl_sect,"btn_r",Rbtn);
554 zc_set_config(ctrl_sect,"btn_p",Pbtn);
555 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
556 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
557 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
558 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
559
560 zc_set_config(ctrl_sect,"btn_up",DUbtn);
561 zc_set_config(ctrl_sect,"btn_down",DDbtn);
562 zc_set_config(ctrl_sect,"btn_left",DLbtn);
563 zc_set_config(ctrl_sect,"btn_right",DRbtn);
564 }
565 }
566
567 void save_cheatkeys()
568 {
569 char buf[256];
570 for(size_t q = 1; q < Cheat::Last; ++q)
571 {
572 if(!bindable_cheat((Cheat)q)) continue;
573 std::string cheatname = cheat_to_string((Cheat)q);
574 util::lowerstr(cheatname);
575 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
576 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
577 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
578 if(cheatkeys[q][1])
579 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
580 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
581 }
582 }
583
584 void save_game_configs()
585 {
586 packfile_password("");
587
588 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
589
590 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
591 {
592 int o_window_x, o_window_y;
593 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
594 zc_set_config(cfg_sect,"window_x",o_window_x);
595 zc_set_config(cfg_sect,"window_y",o_window_y);
596 }
597
598 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
599 {
600 double monitor_scale = zc_get_monitor_scale();
601 window_width = al_get_display_width(all_get_display()) / monitor_scale;
602 window_height = al_get_display_height(all_get_display()) / monitor_scale;
603 zc_set_config(cfg_sect,"window_width",window_width);
604 zc_set_config(cfg_sect,"window_height",window_height);
605 }
606
607 zc_set_config(cfg_sect,"load_last",loadlast);
608 chop_path(qstdir);
609 zc_set_config(cfg_sect,qst_dir_name,qstdir);
610 zc_set_config("SAVEFILE","save_filename",save_file_name);
611 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
612
613 flush_config_file();
614 #ifdef __EMSCRIPTEN__
615 em_sync_fs();
616 #endif
617 }
618
619 //----------------------------------------------------------------
620
621 // Timers
622
623 28496 void fps_callback()
624 {
625 28496 lastfps=framecnt;
626 28496 dword tempsecs = fps_secs;
627 28496 ++tempsecs;
628 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
629 28496 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
630 28496 ++fps_secs;
631 28496 framecnt=0;
632 28496 }
633
634 END_OF_FUNCTION(fps_callback)
635
636 31 int32_t Z_init_timers()
637 {
638 static bool didit = false;
639 const static char *err_str = "Couldn't allocate timer";
640 31 err_str = err_str; //Unused variable warning
641
642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(didit)
643 return 1;
644
645 31 didit = true;
646
647 LOCK_VARIABLE(lastfps);
648 LOCK_VARIABLE(framecnt);
649 LOCK_FUNCTION(fps_callback);
650
651
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
652 return 0;
653
654 31 return 1;
655 31 }
656
657 void Z_remove_timers()
658 {
659 remove_int(fps_callback);
660 }
661
662 //----------------------------------------------------------------
663
664 void go()
665 {
666 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
667 }
668
669 void comeback()
670 {
671 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
672 }
673
674 void dump_pal(BITMAP *dest)
675 {
676 for(int32_t i=0; i<256; i++)
677 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
678 }
679
680 //----------------------------------------------------------------
681
682 int game_mouse_index = ZCM_BLANK;
683 static bool system_mouse = false;
684 13 bool sys_mouse()
685 {
686 13 system_mouse = true;
687 13 return MouseSprite::set(ZCM_NORMAL);
688 }
689 376 bool game_mouse()
690 {
691 376 system_mouse = false;
692 376 return MouseSprite::set(game_mouse_index);
693 }
694 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
695 {
696 if(!bmp)
697 return;
698 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
699 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
700 if(bmp->w == scaledw && bmp->h == scaledh)
701 user_scale = false;
702 if(user_scale || sys_recolor)
703 {
704 if(!user_scale) scale = 1;
705 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
706 if(user_scale)
707 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
708 else
709 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
710 if(sys_recolor)
711 recolor_mouse(tmpbmp);
712 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
713 destroy_bitmap(tmpbmp);
714 }
715 else
716 {
717 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
718 }
719 }
720
721 //Handles converting the mouse sprite from the .dat file
722 31 void recolor_mouse(BITMAP* bmp)
723 {
724
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 31 times.
527 for(int32_t x = 0; x < bmp->w; ++x)
725 {
726
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 496 times.
8432 for(int32_t y = 0; y < bmp->h; ++y)
727 {
728 7936 int32_t color = getpixel(bmp, x, y);
729
5/5
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 682 times.
✓ Branch 3 taken 713 times.
✓ Branch 4 taken 558 times.
7936 switch(color)
730 {
731 case dvc(1):
732 589 color = jwin_pal[jcCURSORMISC];
733 589 break;
734 case dvc(2):
735 682 color = jwin_pal[jcCURSOROUTLINE];
736 682 break;
737 case dvc(3):
738 713 color = jwin_pal[jcCURSORLIGHT];
739 713 break;
740 case dvc(5):
741 558 color = jwin_pal[jcCURSORDARK];
742 558 break;
743 default:
744 5394 continue;
745 }
746 2542 putpixel(bmp, x, y, color);
747 2542 }
748 496 }
749 31 }
750 31 void load_mouse()
751 {
752 31 system_pal();
753 31 MouseSprite::set(-1);
754 31 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
755 31 int32_t sz = 16*scale;
756
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 31 times.
62 for(int32_t j = 0; j < 1; ++j)
757 {
758 31 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
759
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(zcmouse[j])
760 destroy_bitmap(zcmouse[j]);
761 31 zcmouse[j] = create_bitmap_ex(8,sz,sz);
762 31 clear_bitmap(zcmouse[j]);
763 31 clear_bitmap(tmpbmp);
764 31 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
765 31 recolor_mouse(tmpbmp);
766
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(sz!=16)
767 31 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
768 else
769 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
770 31 destroy_bitmap(tmpbmp);
771 31 }
772 31 zc_set_palette(*hw_palette);
773
774 31 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
775 31 clear_bitmap(blankmouse);
776
777 31 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
778 31 MouseSprite::assign(ZCM_BLANK, blankmouse);
779 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
780
781 //Reload the mouse
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(system_mouse)
783 sys_mouse();
784 31 else game_mouse();
785
786 31 destroy_bitmap(blankmouse);
787 31 game_pal();
788 31 }
789
790 // sets the video mode and initializes the palette and mouse sprite
791 31 bool game_vid_mode(int32_t mode,int32_t wait)
792 {
793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
794 {
795 return false;
796 }
797
798 31 scrx = (resx-320)>>1;
799 31 scry = (resy-240)>>1;
800
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 31 times.
62 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
801 31 zcmouse[q] = NULL;
802 31 load_mouse();
803
804
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 31 times.
527 for(int32_t i=240; i<256; i++)
805 496 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
806
807 31 zc_set_palette(RAMpal);
808 31 clear_to_color(screen,BLACK);
809
810 31 rest(wait);
811 31 return true;
812 31 }
813
814 6 void null_quest()
815 {
816 char qstdat_string[2048];
817 6 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
818 6 strcat(qstdat_string,"#NESQST_NEW_QST");
819
820 #ifdef __EMSCRIPTEN__
821 // The quest template data file is not included because it's really big and isn't really needed
822 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
823 // which is much smaller.
824 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
825 #endif
826
827 6 byte skip_flags[4] = { 0 };
828
829 6 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
830 6 }
831
832 6 void init_NES_mode()
833 {
834 /*
835 // qst.dat may not load correctly without this...
836 QHeader.templatepath[0]='\0';
837
838 if(!init_colordata(true, &QHeader, &QMisc))
839 {
840 return;
841 }
842
843 loadfullpal();
844 init_tiles(false, &QHeader);
845 */
846 6 null_quest();
847 6 }
848
849 //----------------------------------------------------------------
850
851 qword trianglelines[16]=
852 {
853 0x0000000000000000ULL,
854 0xFD00000000000000ULL,
855 0xFDFD000000000000ULL,
856 0xFDFDFD0000000000ULL,
857 0xFDFDFDFD00000000ULL,
858 0xFDFDFDFDFD000000ULL,
859 0xFDFDFDFDFDFD0000ULL,
860 0xFDFDFDFDFDFDFD00ULL,
861 0xFDFDFDFDFDFDFDFDULL,
862 0x00FDFDFDFDFDFDFDULL,
863 0x0000FDFDFDFDFDFDULL,
864 0x000000FDFDFDFDFDULL,
865 0x00000000FDFDFDFDULL,
866 0x0000000000FDFDFDULL,
867 0x000000000000FDFDULL,
868 0x00000000000000FDULL,
869 };
870
871 word screen_triangles[28][32];
872 /*
873 qword triangles[4][16]= //[direction][value]
874 {
875 {
876 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
877 },
878 {
879 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
880 },
881 {
882 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
883 },
884 {
885 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
886 }
887 };
888 */
889
890
891 /*
892 byte triangles[4][16][8]= //[direction][value][line]
893 {
894 {
895 {
896 0, 0, 0, 0, 0, 0, 0, 0
897 },
898 {
899 1, 0, 0, 0, 0, 0, 0, 0
900 },
901 {
902 2, 1, 0, 0, 0, 0, 0, 0
903 },
904 {
905 3, 2, 1, 0, 0, 0, 0, 0
906 },
907 {
908 4, 3, 2, 1, 0, 0, 0, 0
909 },
910 {
911 5, 4, 3, 2, 1, 0, 0, 0
912 },
913 {
914 6, 5, 4, 3, 2, 1, 0, 0
915 },
916 {
917 7, 6, 5, 4, 3, 2, 1, 0
918 },
919 {
920 8, 7, 6, 5, 4, 3, 2, 1
921 },
922 {
923 8, 8, 7, 6, 5, 4, 3, 2
924 },
925 {
926 8, 8, 8, 7, 6, 5, 4, 3
927 },
928 {
929 8, 8, 8, 8, 7, 6, 5, 4
930 },
931 {
932 8, 8, 8, 8, 8, 7, 6, 5
933 },
934 {
935 8, 8, 8, 8, 8, 8, 7, 6
936 },
937 {
938 8, 8, 8, 8, 8, 8, 8, 7
939 },
940 {
941 8, 8, 8, 8, 8, 8, 8, 8
942 }
943 },
944 {
945 {
946 0, 0, 0, 0, 0, 0, 0, 0
947 },
948 {
949 15, 0, 0, 0, 0, 0, 0, 0
950 },
951 {
952 14, 15, 0, 0, 0, 0, 0, 0
953 },
954 {
955 13, 14, 15, 0, 0, 0, 0, 0
956 },
957 {
958 12, 13, 14, 15, 0, 0, 0, 0
959 },
960 {
961 11, 12, 13, 14, 15, 0, 0, 0
962 },
963 {
964 10, 11, 12, 13, 14, 15, 0, 0
965 },
966 {
967 9, 10, 11, 12, 13, 14, 15, 0
968 },
969 {
970 8, 9, 10, 11, 12, 13, 14, 15
971 },
972 {
973 8, 8, 9, 10, 11, 12, 13, 14
974 },
975 {
976 8, 8, 8, 9, 10, 11, 12, 13
977 },
978 {
979 8, 8, 8, 8, 9, 10, 11, 12
980 },
981 {
982 8, 8, 8, 8, 8, 9, 10, 11
983 },
984 {
985 8, 8, 8, 8, 8, 8, 9, 10
986 },
987 {
988 8, 8, 8, 8, 8, 8, 8, 9
989 },
990 {
991 8, 8, 8, 8, 8, 8, 8, 8
992 }
993 },
994 {
995 {
996 0, 0, 0, 0, 0, 0, 0, 0
997 },
998 {
999 0, 0, 0, 0, 0, 0, 0, 1
1000 },
1001 {
1002 0, 0, 0, 0, 0, 0, 1, 2
1003 },
1004 {
1005 0, 0, 0, 0, 0, 1, 2, 3
1006 },
1007 {
1008 0, 0, 0, 0, 1, 2, 3, 4
1009 },
1010 {
1011 0, 0, 0, 1, 2, 3, 4, 5
1012 },
1013 {
1014 0, 0, 1, 2, 3, 4, 5, 6
1015 },
1016 {
1017 0, 1, 2, 3, 4, 5, 6, 7
1018 },
1019 {
1020 1, 2, 3, 4, 5, 6, 7, 8
1021 },
1022 {
1023 2, 3, 4, 5, 6, 7, 8, 8
1024 },
1025 {
1026 3, 4, 5, 6, 7, 8, 8, 8
1027 },
1028 {
1029 4, 5, 6, 7, 8, 8, 8, 8
1030 },
1031 {
1032 5, 6, 7, 8, 8, 8, 8, 8
1033 },
1034 {
1035 6, 7, 8, 8, 8, 8, 8, 8
1036 },
1037 {
1038 7, 8, 8, 8, 8, 8, 8, 8
1039 },
1040 {
1041 8, 8, 8, 8, 8, 8, 8, 8
1042 }
1043 },
1044 {
1045 {
1046 0, 0, 0, 0, 0, 0, 0, 0
1047 },
1048 {
1049 0, 0, 0, 0, 0, 0, 0, 15
1050 },
1051 {
1052 0, 0, 0, 0, 0, 0, 15, 14
1053 },
1054 {
1055 0, 0, 0, 0, 0, 15, 14, 13
1056 },
1057 {
1058 0, 0, 0, 0, 15, 14, 13, 12
1059 },
1060 {
1061 0, 0, 0, 15, 14, 13, 12, 11
1062 },
1063 {
1064 0, 0, 15, 14, 13, 12, 11, 10
1065 },
1066 {
1067 0, 15, 14, 13, 12, 11, 10, 9
1068 },
1069 {
1070 15, 14, 13, 12, 11, 10, 9, 8
1071 },
1072 {
1073 14, 13, 12, 11, 10, 9, 8, 8
1074 },
1075 {
1076 13, 12, 11, 10, 9, 8, 8, 8
1077 },
1078 {
1079 12, 11, 10, 9, 8, 8, 8, 8
1080 },
1081 {
1082 11, 10, 9, 8, 8, 8, 8, 8
1083 },
1084 {
1085 10, 9, 8, 8, 8, 8, 8, 8
1086 },
1087 {
1088 9, 8, 8, 8, 8, 8, 8, 8
1089 },
1090 {
1091 8, 8, 8, 8, 8, 8, 8, 8
1092 }
1093 }
1094 };
1095 */
1096
1097
1098
1099 /*
1100 for (int32_t blockrow=0; blockrow<30; ++i)
1101 {
1102 for (int32_t linerow=0; linerow<8; ++i)
1103 {
1104 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1105 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1106 {
1107 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1108 ++triangleline;
1109 }
1110 }
1111 }
1112 */
1113
1114 // the ULL suffixes are to prevent this warning:
1115 // warning: integer constant is too large for "int32_t" type
1116
1117 qword triangles[4][16][8]= //[direction][value][line]
1118 {
1119 {
1120 {
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL,
1128 0x0000000000000000ULL
1129 },
1130 {
1131 0xFD00000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL,
1138 0x0000000000000000ULL
1139 },
1140 {
1141 0xFDFD000000000000ULL,
1142 0xFD00000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL
1149 },
1150 {
1151 0xFDFDFD0000000000ULL,
1152 0xFDFD000000000000ULL,
1153 0xFD00000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL
1159 },
1160 {
1161 0xFDFDFDFD00000000ULL,
1162 0xFDFDFD0000000000ULL,
1163 0xFDFD000000000000ULL,
1164 0xFD00000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL
1169 },
1170 {
1171 0xFDFDFDFDFD000000ULL,
1172 0xFDFDFDFD00000000ULL,
1173 0xFDFDFD0000000000ULL,
1174 0xFDFD000000000000ULL,
1175 0xFD00000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL
1179 },
1180 {
1181 0xFDFDFDFDFDFD0000ULL,
1182 0xFDFDFDFDFD000000ULL,
1183 0xFDFDFDFD00000000ULL,
1184 0xFDFDFD0000000000ULL,
1185 0xFDFD000000000000ULL,
1186 0xFD00000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL
1189 },
1190 {
1191 0xFDFDFDFDFDFDFD00ULL,
1192 0xFDFDFDFDFDFD0000ULL,
1193 0xFDFDFDFDFD000000ULL,
1194 0xFDFDFDFD00000000ULL,
1195 0xFDFDFD0000000000ULL,
1196 0xFDFD000000000000ULL,
1197 0xFD00000000000000ULL,
1198 0x0000000000000000ULL
1199 },
1200 {
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFD00ULL,
1203 0xFDFDFDFDFDFD0000ULL,
1204 0xFDFDFDFDFD000000ULL,
1205 0xFDFDFDFD00000000ULL,
1206 0xFDFDFD0000000000ULL,
1207 0xFDFD000000000000ULL,
1208 0xFD00000000000000ULL
1209 },
1210 {
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFD00ULL,
1214 0xFDFDFDFDFDFD0000ULL,
1215 0xFDFDFDFDFD000000ULL,
1216 0xFDFDFDFD00000000ULL,
1217 0xFDFDFD0000000000ULL,
1218 0xFDFD000000000000ULL
1219 },
1220 {
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFD00ULL,
1225 0xFDFDFDFDFDFD0000ULL,
1226 0xFDFDFDFDFD000000ULL,
1227 0xFDFDFDFD00000000ULL,
1228 0xFDFDFD0000000000ULL
1229 },
1230 {
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFD00ULL,
1236 0xFDFDFDFDFDFD0000ULL,
1237 0xFDFDFDFDFD000000ULL,
1238 0xFDFDFDFD00000000ULL
1239 },
1240 {
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFD00ULL,
1247 0xFDFDFDFDFDFD0000ULL,
1248 0xFDFDFDFDFD000000ULL
1249 },
1250 {
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL,
1257 0xFDFDFDFDFDFDFD00ULL,
1258 0xFDFDFDFDFDFD0000ULL
1259 },
1260 {
1261 0xFDFDFDFDFDFDFDFDULL,
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFDFDULL,
1268 0xFDFDFDFDFDFDFD00ULL
1269 },
1270 {
1271 0xFDFDFDFDFDFDFDFDULL,
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0xFDFDFDFDFDFDFDFDULL,
1278 0xFDFDFDFDFDFDFDFDULL
1279 }
1280 },
1281 {
1282 {
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL,
1290 0x0000000000000000ULL
1291 },
1292 {
1293 0x00000000000000FDULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL,
1300 0x0000000000000000ULL
1301 },
1302 {
1303 0x000000000000FDFDULL,
1304 0x00000000000000FDULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL
1311 },
1312 {
1313 0x0000000000FDFDFDULL,
1314 0x000000000000FDFDULL,
1315 0x00000000000000FDULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL
1321 },
1322 {
1323 0x00000000FDFDFDFDULL,
1324 0x0000000000FDFDFDULL,
1325 0x000000000000FDFDULL,
1326 0x00000000000000FDULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL
1331 },
1332 {
1333 0x000000FDFDFDFDFDULL,
1334 0x00000000FDFDFDFDULL,
1335 0x0000000000FDFDFDULL,
1336 0x000000000000FDFDULL,
1337 0x00000000000000FDULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0x0000000000000000ULL
1341 },
1342 {
1343 0x0000FDFDFDFDFDFDULL,
1344 0x000000FDFDFDFDFDULL,
1345 0x00000000FDFDFDFDULL,
1346 0x0000000000FDFDFDULL,
1347 0x000000000000FDFDULL,
1348 0x00000000000000FDULL,
1349 0x0000000000000000ULL,
1350 0x0000000000000000ULL
1351 },
1352 {
1353 0x00FDFDFDFDFDFDFDULL,
1354 0x0000FDFDFDFDFDFDULL,
1355 0x000000FDFDFDFDFDULL,
1356 0x00000000FDFDFDFDULL,
1357 0x0000000000FDFDFDULL,
1358 0x000000000000FDFDULL,
1359 0x00000000000000FDULL,
1360 0x0000000000000000ULL
1361 },
1362 {
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0x00FDFDFDFDFDFDFDULL,
1365 0x0000FDFDFDFDFDFDULL,
1366 0x000000FDFDFDFDFDULL,
1367 0x00000000FDFDFDFDULL,
1368 0x0000000000FDFDFDULL,
1369 0x000000000000FDFDULL,
1370 0x00000000000000FDULL
1371 },
1372 {
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0x00FDFDFDFDFDFDFDULL,
1376 0x0000FDFDFDFDFDFDULL,
1377 0x000000FDFDFDFDFDULL,
1378 0x00000000FDFDFDFDULL,
1379 0x0000000000FDFDFDULL,
1380 0x000000000000FDFDULL
1381 },
1382 {
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0x00FDFDFDFDFDFDFDULL,
1387 0x0000FDFDFDFDFDFDULL,
1388 0x000000FDFDFDFDFDULL,
1389 0x00000000FDFDFDFDULL,
1390 0x0000000000FDFDFDULL
1391 },
1392 {
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0xFDFDFDFDFDFDFDFDULL,
1397 0x00FDFDFDFDFDFDFDULL,
1398 0x0000FDFDFDFDFDFDULL,
1399 0x000000FDFDFDFDFDULL,
1400 0x00000000FDFDFDFDULL
1401 },
1402 {
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0x00FDFDFDFDFDFDFDULL,
1409 0x0000FDFDFDFDFDFDULL,
1410 0x000000FDFDFDFDFDULL
1411 },
1412 {
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL,
1418 0xFDFDFDFDFDFDFDFDULL,
1419 0x00FDFDFDFDFDFDFDULL,
1420 0x0000FDFDFDFDFDFDULL
1421 },
1422 {
1423 0xFDFDFDFDFDFDFDFDULL,
1424 0xFDFDFDFDFDFDFDFDULL,
1425 0xFDFDFDFDFDFDFDFDULL,
1426 0xFDFDFDFDFDFDFDFDULL,
1427 0xFDFDFDFDFDFDFDFDULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0x00FDFDFDFDFDFDFDULL
1431 },
1432 {
1433 0xFDFDFDFDFDFDFDFDULL,
1434 0xFDFDFDFDFDFDFDFDULL,
1435 0xFDFDFDFDFDFDFDFDULL,
1436 0xFDFDFDFDFDFDFDFDULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL
1441 }
1442 },
1443 {
1444 {
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0x0000000000000000ULL,
1449 0x0000000000000000ULL,
1450 0x0000000000000000ULL,
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL
1453 },
1454 {
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0x0000000000000000ULL,
1458 0x0000000000000000ULL,
1459 0x0000000000000000ULL,
1460 0x0000000000000000ULL,
1461 0x0000000000000000ULL,
1462 0xFD00000000000000ULL
1463 },
1464 {
1465 0x0000000000000000ULL,
1466 0x0000000000000000ULL,
1467 0x0000000000000000ULL,
1468 0x0000000000000000ULL,
1469 0x0000000000000000ULL,
1470 0x0000000000000000ULL,
1471 0xFD00000000000000ULL,
1472 0xFDFD000000000000ULL
1473 },
1474 {
1475 0x0000000000000000ULL,
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0xFD00000000000000ULL,
1481 0xFDFD000000000000ULL,
1482 0xFDFDFD0000000000ULL
1483 },
1484 {
1485 0x0000000000000000ULL,
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0xFD00000000000000ULL,
1490 0xFDFD000000000000ULL,
1491 0xFDFDFD0000000000ULL,
1492 0xFDFDFDFD00000000ULL
1493 },
1494 {
1495 0x0000000000000000ULL,
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0xFD00000000000000ULL,
1499 0xFDFD000000000000ULL,
1500 0xFDFDFD0000000000ULL,
1501 0xFDFDFDFD00000000ULL,
1502 0xFDFDFDFDFD000000ULL
1503 },
1504 {
1505 0x0000000000000000ULL,
1506 0x0000000000000000ULL,
1507 0xFD00000000000000ULL,
1508 0xFDFD000000000000ULL,
1509 0xFDFDFD0000000000ULL,
1510 0xFDFDFDFD00000000ULL,
1511 0xFDFDFDFDFD000000ULL,
1512 0xFDFDFDFDFDFD0000ULL
1513 },
1514 {
1515 0x0000000000000000ULL,
1516 0xFD00000000000000ULL,
1517 0xFDFD000000000000ULL,
1518 0xFDFDFD0000000000ULL,
1519 0xFDFDFDFD00000000ULL,
1520 0xFDFDFDFDFD000000ULL,
1521 0xFDFDFDFDFDFD0000ULL,
1522 0xFDFDFDFDFDFDFD00ULL
1523 },
1524 {
1525 0xFD00000000000000ULL,
1526 0xFDFD000000000000ULL,
1527 0xFDFDFD0000000000ULL,
1528 0xFDFDFDFD00000000ULL,
1529 0xFDFDFDFDFD000000ULL,
1530 0xFDFDFDFDFDFD0000ULL,
1531 0xFDFDFDFDFDFDFD00ULL,
1532 0xFDFDFDFDFDFDFDFDULL
1533 },
1534 {
1535 0xFDFD000000000000ULL,
1536 0xFDFDFD0000000000ULL,
1537 0xFDFDFDFD00000000ULL,
1538 0xFDFDFDFDFD000000ULL,
1539 0xFDFDFDFDFDFD0000ULL,
1540 0xFDFDFDFDFDFDFD00ULL,
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL
1543 },
1544 {
1545 0xFDFDFD0000000000ULL,
1546 0xFDFDFDFD00000000ULL,
1547 0xFDFDFDFDFD000000ULL,
1548 0xFDFDFDFDFDFD0000ULL,
1549 0xFDFDFDFDFDFDFD00ULL,
1550 0xFDFDFDFDFDFDFDFDULL,
1551 0xFDFDFDFDFDFDFDFDULL,
1552 0xFDFDFDFDFDFDFDFDULL
1553 },
1554 {
1555 0xFDFDFDFD00000000ULL,
1556 0xFDFDFDFDFD000000ULL,
1557 0xFDFDFDFDFDFD0000ULL,
1558 0xFDFDFDFDFDFDFD00ULL,
1559 0xFDFDFDFDFDFDFDFDULL,
1560 0xFDFDFDFDFDFDFDFDULL,
1561 0xFDFDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL
1563 },
1564 {
1565 0xFDFDFDFDFD000000ULL,
1566 0xFDFDFDFDFDFD0000ULL,
1567 0xFDFDFDFDFDFDFD00ULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL
1573 },
1574 {
1575 0xFDFDFDFDFDFD0000ULL,
1576 0xFDFDFDFDFDFDFD00ULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL
1583 },
1584 {
1585 0xFDFDFDFDFDFDFD00ULL,
1586 0xFDFDFDFDFDFDFDFDULL,
1587 0xFDFDFDFDFDFDFDFDULL,
1588 0xFDFDFDFDFDFDFDFDULL,
1589 0xFDFDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL
1593 },
1594 {
1595 0xFDFDFDFDFDFDFDFDULL,
1596 0xFDFDFDFDFDFDFDFDULL,
1597 0xFDFDFDFDFDFDFDFDULL,
1598 0xFDFDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL
1603 }
1604 },
1605 {
1606 {
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x0000000000000000ULL,
1611 0x0000000000000000ULL,
1612 0x0000000000000000ULL,
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL
1615 },
1616 {
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x0000000000000000ULL,
1620 0x0000000000000000ULL,
1621 0x0000000000000000ULL,
1622 0x0000000000000000ULL,
1623 0x0000000000000000ULL,
1624 0x00000000000000FDULL
1625 },
1626 {
1627 0x0000000000000000ULL,
1628 0x0000000000000000ULL,
1629 0x0000000000000000ULL,
1630 0x0000000000000000ULL,
1631 0x0000000000000000ULL,
1632 0x0000000000000000ULL,
1633 0x00000000000000FDULL,
1634 0x000000000000FDFDULL
1635 },
1636 {
1637 0x0000000000000000ULL,
1638 0x0000000000000000ULL,
1639 0x0000000000000000ULL,
1640 0x0000000000000000ULL,
1641 0x0000000000000000ULL,
1642 0x00000000000000FDULL,
1643 0x000000000000FDFDULL,
1644 0x0000000000FDFDFDULL
1645 },
1646 {
1647 0x0000000000000000ULL,
1648 0x0000000000000000ULL,
1649 0x0000000000000000ULL,
1650 0x0000000000000000ULL,
1651 0x00000000000000FDULL,
1652 0x000000000000FDFDULL,
1653 0x0000000000FDFDFDULL,
1654 0x00000000FDFDFDFDULL
1655 },
1656 {
1657 0x0000000000000000ULL,
1658 0x0000000000000000ULL,
1659 0x0000000000000000ULL,
1660 0x00000000000000FDULL,
1661 0x000000000000FDFDULL,
1662 0x0000000000FDFDFDULL,
1663 0x00000000FDFDFDFDULL,
1664 0x000000FDFDFDFDFDULL
1665 },
1666 {
1667 0x0000000000000000ULL,
1668 0x0000000000000000ULL,
1669 0x00000000000000FDULL,
1670 0x000000000000FDFDULL,
1671 0x0000000000FDFDFDULL,
1672 0x00000000FDFDFDFDULL,
1673 0x000000FDFDFDFDFDULL,
1674 0x0000FDFDFDFDFDFDULL
1675 },
1676 {
1677 0x0000000000000000ULL,
1678 0x00000000000000FDULL,
1679 0x000000000000FDFDULL,
1680 0x0000000000FDFDFDULL,
1681 0x00000000FDFDFDFDULL,
1682 0x000000FDFDFDFDFDULL,
1683 0x0000FDFDFDFDFDFDULL,
1684 0x00FDFDFDFDFDFDFDULL
1685 },
1686 {
1687 0x00000000000000FDULL,
1688 0x000000000000FDFDULL,
1689 0x0000000000FDFDFDULL,
1690 0x00000000FDFDFDFDULL,
1691 0x000000FDFDFDFDFDULL,
1692 0x0000FDFDFDFDFDFDULL,
1693 0x00FDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL
1695 },
1696 {
1697 0x000000000000FDFDULL,
1698 0x0000000000FDFDFDULL,
1699 0x00000000FDFDFDFDULL,
1700 0x000000FDFDFDFDFDULL,
1701 0x0000FDFDFDFDFDFDULL,
1702 0x00FDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL
1705 },
1706 {
1707 0x0000000000FDFDFDULL,
1708 0x00000000FDFDFDFDULL,
1709 0x000000FDFDFDFDFDULL,
1710 0x0000FDFDFDFDFDFDULL,
1711 0x00FDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL,
1714 0xFDFDFDFDFDFDFDFDULL
1715 },
1716 {
1717 0x00000000FDFDFDFDULL,
1718 0x000000FDFDFDFDFDULL,
1719 0x0000FDFDFDFDFDFDULL,
1720 0x00FDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL,
1722 0xFDFDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL
1725 },
1726 {
1727 0x000000FDFDFDFDFDULL,
1728 0x0000FDFDFDFDFDFDULL,
1729 0x00FDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL
1735 },
1736 {
1737 0x0000FDFDFDFDFDFDULL,
1738 0x00FDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL,
1742 0xFDFDFDFDFDFDFDFDULL,
1743 0xFDFDFDFDFDFDFDFDULL,
1744 0xFDFDFDFDFDFDFDFDULL
1745 },
1746 {
1747 0x00FDFDFDFDFDFDFDULL,
1748 0xFDFDFDFDFDFDFDFDULL,
1749 0xFDFDFDFDFDFDFDFDULL,
1750 0xFDFDFDFDFDFDFDFDULL,
1751 0xFDFDFDFDFDFDFDFDULL,
1752 0xFDFDFDFDFDFDFDFDULL,
1753 0xFDFDFDFDFDFDFDFDULL,
1754 0xFDFDFDFDFDFDFDFDULL
1755 },
1756 {
1757 0xFDFDFDFDFDFDFDFDULL,
1758 0xFDFDFDFDFDFDFDFDULL,
1759 0xFDFDFDFDFDFDFDFDULL,
1760 0xFDFDFDFDFDFDFDFDULL,
1761 0xFDFDFDFDFDFDFDFDULL,
1762 0xFDFDFDFDFDFDFDFDULL,
1763 0xFDFDFDFDFDFDFDFDULL,
1764 0xFDFDFDFDFDFDFDFDULL
1765 }
1766 }
1767 };
1768
1769 int32_t black_opening_count=0;
1770 int32_t black_opening_x,black_opening_y;
1771 int32_t black_opening_shape;
1772
1773 977 int32_t choose_opening_shape()
1774 {
1775 // First, count how many bits are set
1776 977 int32_t numBits=0;
1777 int32_t bitCounter;
1778
1779
2/2
✓ Branch 0 taken 4885 times.
✓ Branch 1 taken 977 times.
5862 for(int32_t i=0; i<bosMAX; i++)
1780 {
1781
2/2
✓ Branch 0 taken 3692 times.
✓ Branch 1 taken 1193 times.
4885 if(COOLSCROLL&(1<<i))
1782 1193 numBits++;
1783 4885 }
1784
1785 // Shouldn't happen...
1786
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if(numBits==0)
1787 return bosCIRCLE;
1788
1789 // Pick a bit
1790 977 bitCounter=zc_rand()%numBits+1;
1791
1792
2/2
✓ Branch 0 taken 1189 times.
✓ Branch 1 taken 26 times.
1215 for(int32_t i=0; i<bosMAX; i++)
1793 {
1794 // If this bit is set, decrement the bit counter
1795
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1107 times.
1189 if(COOLSCROLL&(1<<i))
1796 1107 bitCounter--;
1797
1798 // When the counter hits 0, return a value based on
1799 // which bit it stopped on.
1800 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1801
2/2
✓ Branch 0 taken 951 times.
✓ Branch 1 taken 238 times.
1189 if(bitCounter==0)
1802 951 return i;
1803 238 }
1804
1805 // Shouldn't be necessary, but the compiler might complain, at least
1806 26 return bosCIRCLE;
1807 977 }
1808
1809 275 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1810 {
1811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275 times.
275 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1812
1813 275 int32_t w=256, h=224;
1814 275 int32_t blockrows=28, blockcolumns=32;
1815 275 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1816
1817
2/2
✓ Branch 0 taken 7700 times.
✓ Branch 1 taken 275 times.
7975 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1818 {
1819
2/2
✓ Branch 0 taken 246400 times.
✓ Branch 1 taken 7700 times.
254100 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1820 {
1821
2/2
✓ Branch 0 taken 132077 times.
✓ Branch 1 taken 114323 times.
246400 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1822 246400 }
1823 7700 }
1824
1825 275 black_opening_count = 66;
1826 275 black_opening_x = x;
1827 275 black_opening_y = y;
1828 275 lensclk = 0;
1829 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1830
1831
1832
1/2
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
275 if(black_opening_shape == bosFADEBLACK)
1833 {
1834 refreshTints();
1835 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1836 }
1837
1/2
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
275 if(wait)
1838 {
1839 FFCore.warpScriptCheck();
1840 for(int32_t i=0; i<66; i++)
1841 {
1842 draw_screen(tmpscr);
1843 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1844 advanceframe(true);
1845
1846 if(Quit)
1847 {
1848 break;
1849 }
1850 }
1851 }
1852 275 }
1853
1854 702 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1855 {
1856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 702 times.
702 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1857
1858 702 int32_t w=256, h=224;
1859 702 int32_t blockrows=28, blockcolumns=32;
1860 702 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1861
1862
2/2
✓ Branch 0 taken 19656 times.
✓ Branch 1 taken 702 times.
20358 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1863 {
1864
2/2
✓ Branch 0 taken 628992 times.
✓ Branch 1 taken 19656 times.
648648 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1865 {
1866
2/2
✓ Branch 0 taken 289208 times.
✓ Branch 1 taken 339784 times.
628992 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1867 628992 }
1868 19656 }
1869
1870 702 black_opening_count = -66;
1871 702 black_opening_x = x;
1872 702 black_opening_y = y;
1873 702 lensclk = 0;
1874
1/2
✓ Branch 0 taken 702 times.
✗ Branch 1 not taken.
702 if(black_opening_shape == bosFADEBLACK)
1875 {
1876 refreshTints();
1877 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1878 }
1879
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 546 times.
702 if(wait)
1880 {
1881 546 FFCore.warpScriptCheck();
1882
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 36036 times.
36582 for(int32_t i=0; i<66; i++)
1883 {
1884 36036 draw_screen(tmpscr);
1885 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1886 36036 advanceframe(true);
1887
1888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36036 times.
36036 if(Quit)
1889 {
1890 break;
1891 }
1892 36036 }
1893 546 }
1894 702 }
1895
1896 64482 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1897 {
1898 64482 clear_to_color(tmp_scr,BLACK);
1899 64482 int32_t w=256, h=224;
1900
1901
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61314 times.
64482 switch(black_opening_shape)
1902 {
1903 case bosOVAL:
1904 {
1905 858 double new_w=(w/2)+abs(w/2-x);
1906 858 double new_h=(h/2)+abs(h/2-y);
1907 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1908 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1909 858 break;
1910 }
1911
1912 case bosTRIANGLE:
1913 {
1914 660 double new_w=(w/2)+abs(w/2-x);
1915 660 double new_h=(h/2)+abs(h/2-y);
1916 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1917 660 double P2= (PI/2);
1918 660 double P23=(2*PI/3);
1919 660 double P43=(4*PI/3);
1920 660 double Pa= (-4*PI*a/(3*max_a));
1921 660 double angle=P2+Pa;
1922 660 double a0=angle;
1923 660 double a2=angle+P23;
1924 660 double a4=angle+P43;
1925 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1926 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1927 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1928 0);
1929 660 break;
1930 }
1931
1932 case bosSMAS:
1933 {
1934
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1935
1936
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1937 {
1938
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1939 {
1940 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1941
1942
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1943 {
1944 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1945
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1946 11827200 [linerow];
1947 11827200 ++triangleline;
1948
1949
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1950 {
1951 1478400 }
1952 11827200 }
1953 369600 }
1954 46200 }
1955
1956 1650 break;
1957 }
1958
1959 case bosFADEBLACK:
1960 {
1961 if(black_opening_count<0)
1962 {
1963 black_fade(zc_min(-black_opening_count,63));
1964 }
1965 else if(black_opening_count>0)
1966 {
1967 black_fade(63-zc_max(black_opening_count-3,0));
1968 }
1969 else black_fade(0);
1970 return; //no blitting from tmp_scr!
1971 }
1972
1973 61314 case bosCIRCLE:
1974 default:
1975 {
1976 61314 double new_w=(w/2)+abs(w/2-x);
1977 61314 double new_h=(h/2)+abs(h/2-y);
1978 61314 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1979 //circlefill(tmp_scr,x,y,a<<3,0);
1980 61314 circlefill(tmp_scr,x,y,r,0);
1981 61314 break;
1982 }
1983 }
1984
1985 64482 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1986 64482 }
1987
1988
1989 void black_fade(int32_t fadeamnt)
1990 {
1991 for(int32_t i=0; i < 0xEF; i++)
1992 {
1993 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1994 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1995 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1996 }
1997
1998 refreshpal = true;
1999 }
2000
2001 //----------------------------------------------------------------
2002
2003 17710040 bool item_disabled(int32_t item) //is this item disabled?
2004 {
2005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17710040 times.
17710040 return (item>=0 && game->items_off[item] != 0);
2006 }
2007
2008 6249348 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
2009 {
2010
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 6191506 times.
6249348 if(current_item(item_type, true) >=item)
2011 {
2012 57842 return true;
2013 }
2014
2015 6191506 return false;
2016 6249348 }
2017
2018 26017434 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
2019 {
2020
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4758250 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2908079 times.
✓ Branch 6 taken 13808720 times.
✓ Branch 7 taken 4510587 times.
✓ Branch 8 taken 31798 times.
26017434 switch(item_type)
2021 {
2022 case itype_bomb:
2023 case itype_sbomb:
2024 {
2025 int32_t itemid = getItemID(itemsbuf, item_type, it);
2026
2027 if(itemid == -1)
2028 return false;
2029
2030 return (game->get_item(itemid));
2031 }
2032
2033 case itype_clock:
2034 {
2035 4758250 int32_t itemid = getItemID(itemsbuf, item_type, it);
2036
2037
2/4
✓ Branch 0 taken 4758250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4758250 times.
✗ Branch 3 not taken.
4758250 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2038 return (game->get_item(itemid));
2039 4758250 return Hero.getClock()?1:0;
2040 }
2041
2042 case itype_key:
2043 return (game->get_keys()>0);
2044
2045 case itype_magiccontainer:
2046 return (game->get_maxmagic()>=game->get_mp_per_block());
2047
2048 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2049 {
2050
1/3
✓ Branch 0 taken 2908079 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2908079 switch(it)
2051 {
2052 case -2:
2053 {
2054 for(int32_t i=0; i<MAXLEVELS; i++)
2055 {
2056 if(game->lvlitems[i]&liTRIFORCE)
2057 {
2058 return true;
2059 }
2060 }
2061
2062 return false;
2063 }
2064
2065 case -1:
2066 return (game->lvlitems[dlevel]&liTRIFORCE);
2067
2068 default:
2069
2/4
✓ Branch 0 taken 2908079 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2908079 times.
2908079 if(it>=0&&it<MAXLEVELS)
2070 {
2071 2908079 return (game->lvlitems[it]&liTRIFORCE);
2072 }
2073
2074 break;
2075 }
2076
2077 return 0;
2078 }
2079
2080 case itype_map: //it: -2=any, -1=current level, other=that level
2081 {
2082
1/3
✓ Branch 0 taken 13808720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
13808720 switch(it)
2083 {
2084 case -2:
2085 {
2086 for(int32_t i=0; i<MAXLEVELS; i++)
2087 {
2088 if(game->lvlitems[i]&liMAP)
2089 {
2090 return true;
2091 }
2092 }
2093
2094 return false;
2095 }
2096
2097 case -1:
2098 return (game->lvlitems[dlevel]&liMAP)!=0;
2099
2100 default:
2101
2/4
✓ Branch 0 taken 13808720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13808720 times.
13808720 if(it>=0&&it<MAXLEVELS)
2102 {
2103 13808720 return (game->lvlitems[it]&liMAP)!=0;
2104 }
2105
2106 break;
2107 }
2108
2109 return 0;
2110 }
2111
2112 case itype_compass: //it: -2=any, -1=current level, other=that level
2113 {
2114
1/3
✓ Branch 0 taken 4510587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4510587 switch(it)
2115 {
2116 case -2:
2117 {
2118 for(int32_t i=0; i<MAXLEVELS; i++)
2119 {
2120 if(game->lvlitems[i]&liCOMPASS)
2121 {
2122 return true;
2123 }
2124 }
2125
2126 return false;
2127 }
2128
2129 case -1:
2130 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2131
2132 default:
2133
2/4
✓ Branch 0 taken 4510587 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4510587 times.
✗ Branch 3 not taken.
4510587 if(it>=0&&it<MAXLEVELS)
2134 {
2135 4510587 return (game->lvlitems[it]&liCOMPASS)!=0;
2136 }
2137
2138 break;
2139 }
2140 return 0;
2141 }
2142
2143 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2144 {
2145
1/3
✓ Branch 0 taken 31798 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
31798 switch(it)
2146 {
2147 case -2:
2148 {
2149 for(int32_t i=0; i<MAXLEVELS; i++)
2150 {
2151 if(game->lvlitems[i]&liBOSSKEY)
2152 {
2153 return true;
2154 }
2155 }
2156
2157 return false;
2158 }
2159
2160 case -1:
2161 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2162
2163 default:
2164
2/4
✓ Branch 0 taken 31798 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31798 times.
31798 if(it>=0&&it<MAXLEVELS)
2165 {
2166 31798 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2167 }
2168 break;
2169 }
2170 return 0;
2171 }
2172
2173 default:
2174 //it=(1<<(it-1));
2175 /*if (item_type>=itype_max)
2176 {
2177 system_pal();
2178 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2179 game_pal();
2180
2181 return false;
2182 }*/
2183 int32_t itemid = getItemID(itemsbuf, item_type, it);
2184
2185 if(itemid == -1)
2186 return false;
2187
2188 return game->get_item(itemid);
2189 }
2190 26017434 }
2191
2192
2193 80891104 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2194 {
2195
9/9
✓ Branch 0 taken 4758250 times.
✓ Branch 1 taken 42825104 times.
✓ Branch 2 taken 4758250 times.
✓ Branch 3 taken 4758250 times.
✓ Branch 4 taken 4758250 times.
✓ Branch 5 taken 4758250 times.
✓ Branch 6 taken 4758250 times.
✓ Branch 7 taken 4758250 times.
✓ Branch 8 taken 4758250 times.
80891104 switch(item_type)
2196 {
2197 case itype_clock:
2198 {
2199 4758250 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2200
2201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4758250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4758250 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2202 return itemsbuf[maxid].fam_type;
2203
2204 4758250 return has_item(itype_clock,1) ? 1 : 0;
2205 }
2206
2207 case itype_key:
2208 4758250 return game->get_keys();
2209
2210 case itype_lkey:
2211 4758250 return game->lvlkeys[get_dlevel()];
2212
2213 case itype_magiccontainer:
2214 4758250 return game->get_maxmagic()/game->get_mp_per_block();
2215
2216 case itype_triforcepiece:
2217 {
2218 4758250 int32_t count=0;
2219
2220
2/2
✓ Branch 0 taken 2436224000 times.
✓ Branch 1 taken 4758250 times.
2440982250 for(int32_t i=0; i<MAXLEVELS; i++)
2221 {
2222 2436224000 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2223 2436224000 }
2224
2225 4758250 return count;
2226 }
2227
2228 case itype_map:
2229 {
2230 4758250 int32_t count=0;
2231
2232
2/2
✓ Branch 0 taken 2436224000 times.
✓ Branch 1 taken 4758250 times.
2440982250 for(int32_t i=0; i<MAXLEVELS; i++)
2233 {
2234 2436224000 count+=(game->lvlitems[i]&liMAP)?1:0;
2235 2436224000 }
2236
2237 4758250 return count;
2238 }
2239
2240 case itype_compass:
2241 {
2242 4758250 int32_t count=0;
2243
2244
2/2
✓ Branch 0 taken 2436224000 times.
✓ Branch 1 taken 4758250 times.
2440982250 for(int32_t i=0; i<MAXLEVELS; i++)
2245 {
2246 2436224000 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2247 2436224000 }
2248
2249 4758250 return count;
2250 }
2251
2252 case itype_bosskey:
2253 {
2254 4758250 int32_t count=0;
2255
2256
2/2
✓ Branch 0 taken 2436224000 times.
✓ Branch 1 taken 4758250 times.
2440982250 for(int32_t i=0; i<MAXLEVELS; i++)
2257 {
2258 2436224000 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2259 2436224000 }
2260
2261 4758250 return count;
2262 }
2263
2264 default:
2265 42825104 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2266
2267
2/2
✓ Branch 0 taken 8091859 times.
✓ Branch 1 taken 34733245 times.
42825104 if(maxid == -1)
2268 34733245 return 0;
2269
2270 8091859 return itemsbuf[maxid].fam_type;
2271 }
2272 80891104 }
2273
2274 74641756 int32_t current_item(int32_t item_type) //item currently being used
2275 {
2276 74641756 return current_item(item_type, true);
2277 }
2278
2279 31 std::map<int32_t, int32_t> itemcache;
2280
2281 // Not actually used by anything at the moment...
2282 void removeFromItemCache(int32_t itemid)
2283 {
2284 itemcache.erase(itemid);
2285 }
2286
2287 22158 void flushItemCache()
2288 {
2289 22158 itemcache.clear();
2290
2291 //also fix the active subscreen if items were deleted -DD
2292
1/2
✓ Branch 0 taken 22158 times.
✗ Branch 1 not taken.
22158 if(game != NULL)
2293 {
2294 22158 verifyBothWeapons();
2295 22158 load_Sitems(&QMisc);
2296 22158 }
2297 22158 }
2298
2299 // This is used often, so it should be as direct as possible.
2300 2652040155 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2301 {
2302
2/2
✓ Branch 0 taken 2596260043 times.
✓ Branch 1 taken 55780112 times.
2652040155 if(jinx_check)
2303 {
2304
4/4
✓ Branch 0 taken 35618910 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 32212468 times.
✓ Branch 3 taken 3406442 times.
55780112 if(!(HeroSwordClk() || HeroItemClk()))
2305 32212468 jinx_check = false; //not jinxed
2306 55780112 }
2307
4/4
✓ Branch 0 taken 2629708511 times.
✓ Branch 1 taken 22331644 times.
✓ Branch 2 taken 23398308 times.
✓ Branch 3 taken 2606310203 times.
2652040155 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2308 {
2309 2606310203 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2310
2311
2/2
✓ Branch 0 taken 2594997730 times.
✓ Branch 1 taken 11312473 times.
2606310203 if(res != itemcache.end())
2312 2594997730 return res->second;
2313 11312473 }
2314
2315 57042425 int32_t result = -1;
2316 57042425 int32_t highestlevel = -1;
2317
2318
2/2
✓ Branch 0 taken 14602860800 times.
✓ Branch 1 taken 57042425 times.
14659903225 for(int32_t i=0; i<MAXITEMS; i++)
2319 {
2320
5/6
✓ Branch 0 taken 1152146554 times.
✓ Branch 1 taken 13450714246 times.
✓ Branch 2 taken 17146098 times.
✓ Branch 3 taken 1135000456 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17146098 times.
14602860800 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2321 {
2322
4/4
✓ Branch 0 taken 5098258 times.
✓ Branch 1 taken 12047840 times.
✓ Branch 2 taken 1326271 times.
✓ Branch 3 taken 15819827 times.
17146098 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2323 {
2324 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2325
2/2
✓ Branch 0 taken 15819671 times.
✓ Branch 1 taken 156 times.
15819827 if(!checkmagiccost(i))
2326 {
2327
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 144 times.
156 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2328 12 }
2329 15819683 }
2330
6/6
✓ Branch 0 taken 14774091 times.
✓ Branch 1 taken 2371863 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2115175 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 744606 times.
17145954 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2331 {
2332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744606 times.
744606 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2333 744606 continue;
2334 }
2335
2336
2/2
✓ Branch 0 taken 237664 times.
✓ Branch 1 taken 16163684 times.
16401348 if(itemsbuf[i].fam_type >= highestlevel)
2337 {
2338 16163684 highestlevel = itemsbuf[i].fam_type;
2339 16163684 result=i;
2340 16163684 }
2341 16401348 }
2342 14602116050 }
2343
2344
2/2
✓ Branch 0 taken 23567644 times.
✓ Branch 1 taken 33474781 times.
57042425 if(!jinx_check) //Can't cache jinx_check results
2345 33474781 itemcache[itemtype] = result;
2346 57042425 return result;
2347 2652040155 }
2348
2349 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2350 2628787173 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2351 {
2352 2628787173 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2353
2/2
✓ Branch 0 taken 32527130 times.
✓ Branch 1 taken 2596260043 times.
2628787173 if(!jinx_check) //If not already a jinx-immune-only check...
2354 {
2355 //And the player IS jinxed...
2356
4/4
✓ Branch 0 taken 2576364425 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2573007061 times.
2596260043 if(HeroSwordClk() || HeroItemClk())
2357 {
2358 //Then do a jinx-immune-only check here
2359 23252982 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2360 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2361 //Should NOT need a compat rule, as this should always return -1 in old quests.
2362
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22150338 times.
23252982 if(ret2 > -1) return ret2;
2363 22150338 }
2364 2595157399 }
2365 2627684529 return ret;
2366 2628787173 }
2367 16703689 int32_t current_item_power(int32_t itemtype)
2368 {
2369 16703689 int32_t result = current_item_id(itemtype,true);
2370
2/2
✓ Branch 0 taken 12490882 times.
✓ Branch 1 taken 4212807 times.
16703689 return (result<0) ? 0 : itemsbuf[result].power;
2371 }
2372
2373 7 int32_t heart_container_id()
2374 {
2375
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2376 {
2377
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2378 {
2379 7 return i;
2380 }
2381 196 }
2382 return -1;
2383 7 }
2384
2385 4758250 int32_t item_tile_mod()
2386 {
2387 4758250 int32_t tile=0;
2388
2389
2/2
✓ Branch 0 taken 1015443 times.
✓ Branch 1 taken 3742807 times.
4758250 if(game->get_bombs())
2390 {
2391 3742807 int32_t itemid = current_item_id(itype_bomb,false);
2392
3/4
✓ Branch 0 taken 3661748 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3661748 times.
3742807 if(itemid > -1 && checkbunny(itemid))
2393 3661748 tile+=itemsbuf[itemid].ltm;
2394 3742807 }
2395
2396
2/2
✓ Branch 0 taken 3692994 times.
✓ Branch 1 taken 1065256 times.
4758250 if(game->get_sbombs())
2397 {
2398 1065256 int32_t itemid = current_item_id(itype_sbomb,false);
2399
3/4
✓ Branch 0 taken 1063828 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1063828 times.
1065256 if(itemid > -1 && checkbunny(itemid))
2400 1063828 tile+=itemsbuf[itemid].ltm;
2401 1065256 }
2402
2403
2/2
✓ Branch 0 taken 4656493 times.
✓ Branch 1 taken 101757 times.
4758250 if(current_item(itype_clock))
2404 {
2405 101757 int32_t itemid =
2406
1/2
✓ Branch 0 taken 101757 times.
✗ Branch 1 not taken.
101757 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2407 ? iClock
2408 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2409
2/4
✓ Branch 0 taken 101757 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 101757 times.
101757 if(itemid > -1 && checkbunny(itemid))
2410 101757 tile+=itemsbuf[itemid].ltm;
2411 101757 }
2412
2413
2/2
✓ Branch 0 taken 3846530 times.
✓ Branch 1 taken 911720 times.
4758250 if(current_item(itype_key))
2414 {
2415 911720 int32_t itemid =
2416
1/2
✓ Branch 0 taken 911720 times.
✗ Branch 1 not taken.
911720 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2417 ? iKey
2418 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2419
2/4
✓ Branch 0 taken 911720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 911720 times.
911720 if(itemid > -1 && checkbunny(itemid))
2420 911720 tile+=itemsbuf[itemid].ltm;
2421 911720 }
2422
2423
2/2
✓ Branch 0 taken 4598997 times.
✓ Branch 1 taken 159253 times.
4758250 if(current_item(itype_lkey))
2424 {
2425 159253 int32_t itemid =
2426
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2427 ? iLevelKey
2428 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2429
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2430 159253 tile+=itemsbuf[itemid].ltm;
2431 159253 }
2432
2433
2/2
✓ Branch 0 taken 985265 times.
✓ Branch 1 taken 3772985 times.
4758250 if(current_item(itype_map))
2434 {
2435 3772985 int32_t itemid =
2436
2/2
✓ Branch 0 taken 3772199 times.
✓ Branch 1 taken 786 times.
3772985 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2437 ? iMap
2438 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2439
2/4
✓ Branch 0 taken 3772985 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3772985 times.
3772985 if(itemid > -1 && checkbunny(itemid))
2440 3772985 tile+=itemsbuf[itemid].ltm;
2441 3772985 }
2442
2443
2/2
✓ Branch 0 taken 938169 times.
✓ Branch 1 taken 3820081 times.
4758250 if(current_item(itype_compass))
2444 {
2445 3820081 int32_t itemid =
2446
2/2
✓ Branch 0 taken 3739022 times.
✓ Branch 1 taken 81059 times.
3820081 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2447 ? iCompass
2448 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2449
2/4
✓ Branch 0 taken 3820081 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3820081 times.
3820081 if(itemid > -1 && checkbunny(itemid))
2450 3820081 tile+=itemsbuf[itemid].ltm;
2451 3820081 }
2452
2453
2/2
✓ Branch 0 taken 2889046 times.
✓ Branch 1 taken 1869204 times.
4758250 if(current_item(itype_bosskey))
2454 {
2455 1869204 int32_t itemid =
2456
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2457 ? iBossKey
2458 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2459
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2460 1869204 tile+=itemsbuf[itemid].ltm;
2461 1869204 }
2462
2463
2/2
✓ Branch 0 taken 2639058 times.
✓ Branch 1 taken 2119192 times.
4758250 if(current_item(itype_magiccontainer))
2464 {
2465 2119192 int32_t itemid =
2466
2/2
✓ Branch 0 taken 2025977 times.
✓ Branch 1 taken 93215 times.
2119192 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2467 ? iMagicC
2468 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2469
3/4
✓ Branch 0 taken 2119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2117322 times.
2119192 if(itemid > -1 && checkbunny(itemid))
2470 2117322 tile+=itemsbuf[itemid].ltm;
2471 2119192 }
2472
2473
2/2
✓ Branch 0 taken 1303692 times.
✓ Branch 1 taken 3454558 times.
4758250 if(current_item(itype_triforcepiece))
2474 {
2475 3454558 int32_t itemid =
2476
1/2
✓ Branch 0 taken 3454558 times.
✗ Branch 1 not taken.
3454558 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2477 ? iTriforce
2478 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2479
2/4
✓ Branch 0 taken 3454558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3454558 times.
3454558 if(itemid > -1 && checkbunny(itemid))
2480 3454558 tile+=itemsbuf[itemid].ltm;
2481 3454558 }
2482
2483
2/2
✓ Branch 0 taken 4758250 times.
✓ Branch 1 taken 2436224000 times.
2440982250 for(int32_t i=0; i<itype_max; i++)
2484 {
2485
2/2
✓ Branch 0 taken 2382618624 times.
✓ Branch 1 taken 53605376 times.
2436224000 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2486 {
2487
2/2
✓ Branch 0 taken 1046980 times.
✓ Branch 1 taken 52558396 times.
53605376 switch(i)
2488 {
2489 case itype_bomb:
2490 case itype_sbomb:
2491 case itype_clock:
2492 case itype_key:
2493 case itype_lkey:
2494 case itype_map:
2495 case itype_compass:
2496 case itype_bosskey:
2497 case itype_magiccontainer:
2498 case itype_triforcepiece:
2499 1046980 continue; //already handled
2500 }
2501 52558396 }
2502 2435177020 int32_t itemid = current_item_id(i,false);
2503
2/2
✓ Branch 0 taken 2430418770 times.
✓ Branch 1 taken 4758250 times.
2435177020 if(i == itype_shield)
2504 4758250 itemid = getCurrentShield(false);
2505
2506
4/4
✓ Branch 0 taken 67171044 times.
✓ Branch 1 taken 2368005976 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 67070063 times.
2435177020 if(itemid < 0 || !checkbunny(itemid))
2507 2368106957 continue;
2508
2509 67070063 itemdata const& itm = itemsbuf[itemid];
2510
2511
2/2
✓ Branch 0 taken 62889335 times.
✓ Branch 1 taken 4180728 times.
67070063 switch(itm.family)
2512 {
2513 case itype_shield:
2514
1/2
✓ Branch 0 taken 4180728 times.
✗ Branch 1 not taken.
4180728 if(itm.flags & ITEM_FLAG9) //active shield
2515 {
2516 if(!usingActiveShield(itemid))
2517 {
2518 tile+=itm.misc6; //'Inactive PTM'
2519 continue;
2520 }
2521 }
2522 4180728 break;
2523 }
2524
2525 67070063 tile+=itm.ltm;
2526 67070063 }
2527
2528 4758250 return tile;
2529 }
2530
2531 4758250 int32_t bunny_tile_mod()
2532 {
2533
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4756380 times.
4758250 if(Hero.BunnyClock())
2534 {
2535 1870 return game->get_bunny_ltm();
2536 }
2537 4756380 return 0;
2538 4758250 }
2539
2540 // Hints are drawn on a separate layer to combo reveals.
2541 16332 void draw_lens_under(BITMAP *dest, bool layer)
2542 {
2543 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2544 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2545 //Lens flag 3: Don't show armos/chest/dive items
2546 //Lens flag 4: Show Raft Paths
2547 //Lens flag 5: Show Invisible Enemies
2548
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2549
2550 16332 int32_t strike_hint_table[11]=
2551 {
2552 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2553 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2554 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2555 };
2556
2557 // int32_t page = tmpscr->cpage;
2558 {
2559 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2560 // int32_t temptimer=0;
2561 16332 int32_t tempitem, tempweapon=0;
2562 16332 strike_hint=strike_hint_table[strike_hint_counter];
2563
2564
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2565 {
2566 492 strike_hint_timer=0;
2567 492 strike_hint_counter=((strike_hint_counter+1)%11);
2568 492 }
2569
2570 16332 ++strike_hint_timer;
2571
2572
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2573 {
2574 2874432 int32_t x = (i & 15) << 4;
2575 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2576 2874432 int32_t tempitemx=-16, tempitemy=-16;
2577 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2578
2579
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2580 {
2581 5748864 int32_t checkflag=0;
2582
2583
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2584 {
2585 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2586 2874432 }
2587 else
2588 {
2589 2874432 checkflag=tmpscr->sflag[i];
2590 }
2591
2592
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2593 {
2594
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2595 {
2596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2597 906 }
2598 else
2599 {
2600 192 checkflag = strike_hint;
2601 }
2602 1098 }
2603
2604
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2605 {
2606 case 0:
2607 case mfZELDA:
2608 case mfPUSHED:
2609 case mfENEMY0:
2610 case mfENEMY1:
2611 case mfENEMY2:
2612 case mfENEMY3:
2613 case mfENEMY4:
2614 case mfENEMY5:
2615 case mfENEMY6:
2616 case mfENEMY7:
2617 case mfENEMY8:
2618 case mfENEMY9:
2619 case mfSINGLE:
2620 case mfSINGLE16:
2621 case mfNOENEMY:
2622 case mfTRAP_H:
2623 case mfTRAP_V:
2624 case mfTRAP_4:
2625 case mfTRAP_LR:
2626 case mfTRAP_UD:
2627 case mfNOGROUNDENEMY:
2628 case mfNOBLOCKS:
2629 case mfSCRIPT1:
2630 case mfSCRIPT2:
2631 case mfSCRIPT3:
2632 case mfSCRIPT4:
2633 case mfSCRIPT5:
2634 case mfSCRIPT6:
2635 case mfSCRIPT7:
2636 case mfSCRIPT8:
2637 case mfSCRIPT9:
2638 case mfSCRIPT10:
2639 case mfSCRIPT11:
2640 case mfSCRIPT12:
2641 case mfSCRIPT13:
2642 case mfSCRIPT14:
2643 case mfSCRIPT15:
2644 case mfSCRIPT16:
2645 case mfSCRIPT17:
2646 case mfSCRIPT18:
2647 case mfSCRIPT19:
2648 case mfSCRIPT20:
2649 case mfPITHOLE:
2650 case mfPITFALLFLOOR:
2651 case mfLAVA:
2652 case mfICE:
2653 case mfICEDAMAGE:
2654 case mfDAMAGE1:
2655 case mfDAMAGE2:
2656 case mfDAMAGE4:
2657 case mfDAMAGE8:
2658 case mfDAMAGE16:
2659 case mfDAMAGE32:
2660 case mfFREEZEALL:
2661 case mfFREZEALLANSFFCS:
2662 case mfFREEZEFFCSOLY:
2663 case mfSCRITPTW1TRIG:
2664 case mfSCRITPTW2TRIG:
2665 case mfSCRITPTW3TRIG:
2666 case mfSCRITPTW4TRIG:
2667 case mfSCRITPTW5TRIG:
2668 case mfSCRITPTW6TRIG:
2669 case mfSCRITPTW7TRIG:
2670 case mfSCRITPTW8TRIG:
2671 case mfSCRITPTW9TRIG:
2672 case mfSCRITPTW10TRIG:
2673 case mfTROWEL:
2674 case mfTROWELNEXT:
2675 case mfTROWELSPECIALITEM:
2676 case mfSLASHPOT:
2677 case mfLIFTPOT:
2678 case mfLIFTORSLASH:
2679 case mfLIFTROCK:
2680 case mfLIFTROCKHEAVY:
2681 case mfDROPITEM:
2682 case mfSPECIALITEM:
2683 case mfDROPKEY:
2684 case mfDROPLKEY:
2685 case mfDROPCOMPASS:
2686 case mfDROPMAP:
2687 case mfDROPBOSSKEY:
2688 case mfSPAWNNPC:
2689 case mfSWITCHHOOK:
2690 case mfSIDEVIEWLADDER:
2691 case mfSIDEVIEWPLATFORM:
2692 case mfNOENEMYSPAWN:
2693 case mfENEMYALL:
2694 case mfNOMIRROR:
2695 case mfUNSAFEGROUND:
2696 case mf168:
2697 case mf169:
2698 case mf170:
2699 case mf171:
2700 case mf172:
2701 case mf173:
2702 case mf174:
2703 case mf175:
2704 case mf176:
2705 case mf177:
2706 case mf178:
2707 case mf179:
2708 case mf180:
2709 case mf181:
2710 case mf182:
2711 case mf183:
2712 case mf184:
2713 case mf185:
2714 case mf186:
2715 case mf187:
2716 case mf188:
2717 case mf189:
2718 case mf190:
2719 case mf191:
2720 case mf192:
2721 case mf193:
2722 case mf194:
2723 case mf195:
2724 case mf196:
2725 case mf197:
2726 case mf198:
2727 case mf199:
2728 case mf200:
2729 case mf201:
2730 case mf202:
2731 case mf203:
2732 case mf204:
2733 case mf205:
2734 case mf206:
2735 case mf207:
2736 case mf208:
2737 case mf209:
2738 case mf210:
2739 case mf211:
2740 case mf212:
2741 case mf213:
2742 case mf214:
2743 case mf215:
2744 case mf216:
2745 case mf217:
2746 case mf218:
2747 case mf219:
2748 case mf220:
2749 case mf221:
2750 case mf222:
2751 case mf223:
2752 case mf224:
2753 case mf225:
2754 case mf226:
2755 case mf227:
2756 case mf228:
2757 case mf229:
2758 case mf230:
2759 case mf231:
2760 case mf232:
2761 case mf233:
2762 case mf234:
2763 case mf235:
2764 case mf236:
2765 case mf237:
2766 case mf238:
2767 case mf239:
2768 case mf240:
2769 case mf241:
2770 case mf242:
2771 case mf243:
2772 case mf244:
2773 case mf245:
2774 case mf246:
2775 case mf247:
2776 case mf248:
2777 case mf249:
2778 case mf250:
2779 case mf251:
2780 case mf252:
2781 case mf253:
2782 case mf254:
2783 case mfEXTENDED:
2784 5706470 break;
2785
2786 case mfPUSHUD:
2787 case mfPUSHLR:
2788 case mfPUSH4:
2789 case mfPUSHU:
2790 case mfPUSHD:
2791 case mfPUSHL:
2792 case mfPUSHR:
2793 case mfPUSHUDNS:
2794 case mfPUSHLRNS:
2795 case mfPUSH4NS:
2796 case mfPUSHUNS:
2797 case mfPUSHDNS:
2798 case mfPUSHLNS:
2799 case mfPUSHRNS:
2800 case mfPUSHUDINS:
2801 case mfPUSHLRINS:
2802 case mfPUSH4INS:
2803 case mfPUSHUINS:
2804 case mfPUSHDINS:
2805 case mfPUSHLINS:
2806 case mfPUSHRINS:
2807
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2808
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2809 {
2810 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2811 }
2812
2813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2814
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2815 {
2816
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2817 {
2818
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2819 {
2820 case cPUSH_HEAVY:
2821 case cPUSH_HW:
2822 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2823 72 tempitemx=x, tempitemy=y;
2824
2825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2826 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2827
2828 72 break;
2829
2830 case cPUSH_HEAVY2:
2831 case cPUSH_HW2:
2832 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2833 63 tempitemx=x, tempitemy=y;
2834
2835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2836 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2837
2838 63 break;
2839 }
2840 1032 }
2841 2438 }
2842
2843 3148 break;
2844
2845 case mfWHISTLE:
2846
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2847 {
2848 tempitem=getItemID(itemsbuf,itype_whistle,1);
2849
2850 if(tempitem<0) break;
2851
2852 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2853 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2854 {
2855 tempitemx=x;
2856 tempitemy=y;
2857 }
2858
2859 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2860 }
2861
2862 2418 break;
2863
2864 //Why is this here?
2865 case mfFAIRY:
2866 case mfMAGICFAIRY:
2867 case mfALLFAIRY:
2868 if(hints)
2869 {
2870 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2871
2872 if(tempitem < 0) break;
2873
2874 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2875 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2876 {
2877 tempitemx=x;
2878 tempitemy=y;
2879 }
2880
2881 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2882 }
2883
2884 break;
2885
2886 case mfANYFIRE:
2887
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2888 {
2889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2890 252 }
2891 else
2892 {
2893 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2894
2895
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2896
2897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2898
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2899 {
2900 189 tempitemx=x;
2901 189 tempitemy=y;
2902 189 }
2903
2904 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2905 }
2906
2907 504 break;
2908
2909 case mfSTRONGFIRE:
2910 if(!hints)
2911 {
2912 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2913 }
2914 else
2915 {
2916 tempitem=getItemID(itemsbuf,itype_candle,2);
2917
2918 if(tempitem<0) break;
2919
2920 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2921 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2922 {
2923 tempitemx=x;
2924 tempitemy=y;
2925 }
2926
2927 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2928 }
2929
2930 break;
2931
2932 case mfMAGICFIRE:
2933 if(!hints)
2934 {
2935 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2936 }
2937 else
2938 {
2939 tempitem=getItemID(itemsbuf,itype_wand,1);
2940
2941 if(tempitem<0) break;
2942
2943 tempweapon=wFire;
2944
2945 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2946 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2947 {
2948 tempitemx=x;
2949 tempitemy=y;
2950 }
2951 else
2952 {
2953 tempweaponx=x;
2954 tempweapony=y;
2955 }
2956
2957 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2958 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2959 }
2960
2961 break;
2962
2963 case mfDIVINEFIRE:
2964 if(!hints)
2965 {
2966 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2967 }
2968 else
2969 {
2970 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2971
2972 if(tempitem<0) break;
2973
2974 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2975 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2976 {
2977 tempitemx=x;
2978 tempitemy=y;
2979 }
2980
2981 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2982 }
2983
2984 break;
2985
2986 case mfARROW:
2987
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2988 {
2989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2990 732 }
2991 else
2992 {
2993 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2994
2995
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2996
2997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2998
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2999 {
3000 61 tempitemx=x;
3001 61 tempitemy=y;
3002 61 }
3003
3004 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3005 }
3006
3007 814 break;
3008
3009 case mfSARROW:
3010 if(!hints)
3011 {
3012 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3013 }
3014 else
3015 {
3016 tempitem=getItemID(itemsbuf,itype_arrow,2);
3017
3018 if(tempitem<0) break;
3019
3020 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3021 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3022 {
3023 tempitemx=x;
3024 tempitemy=y;
3025 }
3026
3027 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3028 }
3029
3030 break;
3031
3032 case mfGARROW:
3033 if(!hints)
3034 {
3035 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3036 }
3037 else
3038 {
3039 tempitem=getItemID(itemsbuf,itype_arrow,3);
3040
3041 if(tempitem<0) break;
3042
3043 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 tempitemx=x;
3047 tempitemy=y;
3048 }
3049
3050 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3051 }
3052
3053 break;
3054
3055 case mfBOMB:
3056
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3057 {
3058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3059 16 }
3060 else
3061 {
3062 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3063 17 tempweapon = wLitBomb;
3064
3065 //if (tempitem<0) break;
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 12 tempweaponx=x;
3070 12 tempweapony=y;
3071 12 }
3072
3073 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3074 }
3075
3076 33 break;
3077
3078 case mfSBOMB:
3079
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3080 {
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3082 48 }
3083 else
3084 {
3085 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3086 //if (tempitem<0) break;
3087 48 tempweapon = wLitSBomb;
3088
3089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3090
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3091 {
3092 36 tempweaponx=x;
3093 36 tempweapony=y;
3094 36 }
3095
3096 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3097 }
3098
3099 96 break;
3100
3101 case mfARMOS_SECRET:
3102
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3103 {
3104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3105 12 }
3106 24 break;
3107
3108 case mfBRANG:
3109
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3110 {
3111 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3112 }
3113 else
3114 {
3115 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3116
3117
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3118
3119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3120
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3121 {
3122 4 tempitemx=x;
3123 4 tempitemy=y;
3124 4 }
3125
3126 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3127 }
3128
3129 5 break;
3130
3131 case mfMBRANG:
3132 if(!hints)
3133 {
3134 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3135 }
3136 else
3137 {
3138 tempitem=getItemID(itemsbuf,itype_brang,2);
3139
3140 if(tempitem<0) break;
3141
3142 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3143 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3144 {
3145 tempitemx=x;
3146 tempitemy=y;
3147 }
3148
3149 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3150 }
3151
3152 break;
3153
3154 case mfFBRANG:
3155 if(!hints)
3156 {
3157 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3158 }
3159 else
3160 {
3161 tempitem=getItemID(itemsbuf,itype_brang,3);
3162
3163 if(tempitem<0) break;
3164
3165 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3166 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3167 {
3168 tempitemx=x;
3169 tempitemy=y;
3170 }
3171
3172 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3173 }
3174
3175 break;
3176
3177 case mfWANDMAGIC:
3178 if(!hints)
3179 {
3180 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3181 }
3182 else
3183 {
3184 tempitem=getItemID(itemsbuf,itype_wand,1);
3185
3186 if(tempitem<0) break;
3187
3188 tempweapon=itemsbuf[tempitem].wpn3;
3189
3190 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3191 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3192 {
3193 tempitemx=x;
3194 tempitemy=y;
3195 }
3196 else
3197 {
3198 tempweaponx=x;
3199 tempweapony=y;
3200 --lens_hint_weapon[wMagic][4];
3201
3202 if(lens_hint_weapon[wMagic][4]<-8)
3203 {
3204 lens_hint_weapon[wMagic][4]=8;
3205 }
3206 }
3207
3208 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3209 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3210 }
3211
3212 break;
3213
3214 case mfREFMAGIC:
3215
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3216 {
3217 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3218 }
3219 else
3220 {
3221 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3222
3223
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3224
3225 16 tempweapon=ewMagic;
3226
3227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3228
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3229 {
3230 13 tempitemx=x;
3231 13 tempitemy=y;
3232 13 }
3233 else
3234 {
3235 3 tempweaponx=x;
3236 3 tempweapony=y;
3237
3238
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3239 {
3240 1 --lens_hint_weapon[ewMagic][4];
3241 1 }
3242 else
3243 {
3244 2 ++lens_hint_weapon[ewMagic][4];
3245 }
3246
3247
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3248 {
3249 lens_hint_weapon[ewMagic][2]=up;
3250 }
3251
3252
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3253 {
3254 2 lens_hint_weapon[ewMagic][2]=down;
3255 2 }
3256 }
3257
3258 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3259 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3260 }
3261
3262 16 break;
3263
3264 case mfREFFIREBALL:
3265
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3266 {
3267 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3268 }
3269 else
3270 {
3271 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3272
3273
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3274
3275 16 tempweapon=ewFireball;
3276
3277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3278
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3279 {
3280 12 tempitemx=x;
3281 12 tempitemy=y;
3282 12 tempweaponx=x;
3283 12 tempweapony=y;
3284 12 ++lens_hint_weapon[ewFireball][3];
3285
3286
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3287 {
3288 1 lens_hint_weapon[ewFireball][3]=-8;
3289 1 lens_hint_weapon[ewFireball][4]=8;
3290 1 }
3291
3292
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3293 {
3294 8 ++lens_hint_weapon[ewFireball][4];
3295 8 }
3296 else
3297 {
3298 4 --lens_hint_weapon[ewFireball][4];
3299 }
3300 12 }
3301
3302 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3303 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3304 }
3305
3306 16 break;
3307
3308 case mfSWORD:
3309
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3310 {
3311 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3312 }
3313 else
3314 {
3315 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3316
3317
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3318
3319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3320
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3321 {
3322 5 tempitemx=x;
3323 5 tempitemy=y;
3324 5 }
3325
3326 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3327 }
3328
3329 7 break;
3330
3331 case mfWSWORD:
3332 if(!hints)
3333 {
3334 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3335 }
3336 else
3337 {
3338 tempitem=getItemID(itemsbuf,itype_sword,2);
3339
3340 if(tempitem<0) break;
3341
3342 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3343 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3344 {
3345 tempitemx=x;
3346 tempitemy=y;
3347 }
3348
3349 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3350 }
3351
3352 break;
3353
3354 case mfMSWORD:
3355 if(!hints)
3356 {
3357 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3358 }
3359 else
3360 {
3361 tempitem=getItemID(itemsbuf,itype_sword,3);
3362
3363 if(tempitem<0) break;
3364
3365 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3366 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3367 {
3368 tempitemx=x;
3369 tempitemy=y;
3370 }
3371
3372 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3373 }
3374
3375 break;
3376
3377 case mfXSWORD:
3378 if(!hints)
3379 {
3380 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3381 }
3382 else
3383 {
3384 tempitem=getItemID(itemsbuf,itype_sword,4);
3385
3386 if(tempitem<0) break;
3387
3388 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3389 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3390 {
3391 tempitemx=x;
3392 tempitemy=y;
3393 }
3394
3395 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3396 }
3397
3398 break;
3399
3400 case mfSWORDBEAM:
3401
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3402 {
3403 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3404 }
3405 else
3406 {
3407 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3408
3409
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3410
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3412
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3413 {
3414 11 tempitemx=x;
3415 11 tempitemy=y;
3416 11 }
3417
3418 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3419 }
3420
3421 16 break;
3422
3423 case mfWSWORDBEAM:
3424 if(!hints)
3425 {
3426 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3427 }
3428 else
3429 {
3430 tempitem=getItemID(itemsbuf,itype_sword,2);
3431
3432 if(tempitem<0) break;
3433
3434 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3435 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3436 {
3437 tempitemx=x;
3438 tempitemy=y;
3439 }
3440
3441 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3442 }
3443
3444 break;
3445
3446 case mfMSWORDBEAM:
3447 if(!hints)
3448 {
3449 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3450 }
3451 else
3452 {
3453 tempitem=getItemID(itemsbuf,itype_sword,3);
3454
3455 if(tempitem<0) break;
3456
3457 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3458 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3459 {
3460 tempitemx=x;
3461 tempitemy=y;
3462 }
3463
3464 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3465 }
3466
3467 break;
3468
3469 case mfXSWORDBEAM:
3470 if(!hints)
3471 {
3472 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3473 }
3474 else
3475 {
3476 tempitem=getItemID(itemsbuf,itype_sword,4);
3477
3478 if(tempitem<0) break;
3479
3480 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3481 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3482 {
3483 tempitemx=x;
3484 tempitemy=y;
3485 }
3486
3487 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3488 }
3489
3490 break;
3491
3492 case mfHOOKSHOT:
3493
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3494 {
3495 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3496 }
3497 else
3498 {
3499 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3500
3501
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3502
3503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3504
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3505 {
3506 12 tempitemx=x;
3507 12 tempitemy=y;
3508 12 }
3509
3510 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3511 }
3512
3513 17 break;
3514
3515 case mfWAND:
3516
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3517 {
3518 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3519 }
3520 else
3521 {
3522 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3523
3524
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3525
3526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3527
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3528 {
3529 28 tempitemx=x;
3530 28 tempitemy=y;
3531 28 }
3532
3533 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3534 }
3535
3536 35 break;
3537
3538 case mfHAMMER:
3539
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3540 {
3541 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3542 }
3543 else
3544 {
3545 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3546
3547
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3548
3549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3550
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3551 {
3552 13 tempitemx=x;
3553 13 tempitemy=y;
3554 13 }
3555
3556 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3557 }
3558
3559 17 break;
3560
3561 case mfARMOS_ITEM:
3562 case mfDIVE_ITEM:
3563
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3564 {
3565 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3566 2064 }
3567 2064 break;
3568
3569 case 16:
3570 case 17:
3571 case 18:
3572 case 19:
3573 case 20:
3574 case 21:
3575 case 22:
3576 case 23:
3577 case 24:
3578 case 25:
3579 case 26:
3580 case 27:
3581 case 28:
3582 case 29:
3583 case 30:
3584 case 31:
3585
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3587 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3588
3589 3618 break;
3590 case mfSECRETSNEXT:
3591 if(!hints)
3592 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3593 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3594
3595 break;
3596
3597 case mfSTRIKE:
3598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3599 {
3600 906 goto special;
3601 }
3602 else
3603 {
3604 break;
3605 }
3606
3607 28640 default: goto special;
3608
3609 special:
3610
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3611 {
3612
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3613 {
3614 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3615 4913 }
3616 6549 }
3617
3618 29546 break;
3619 }
3620 5748864 }
3621 2874432 }
3622
3623
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3624 {
3625
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3626 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3627
3628
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3629 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3630
3631
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3632 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3633
3634
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3635 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3636
3637
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3638 {
3639 43 showbombeddoor(dest, 0);
3640 43 }
3641
3642
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3643 {
3644 39 showbombeddoor(dest, 1);
3645 39 }
3646
3647
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3648 {
3649 showbombeddoor(dest, 2);
3650 }
3651
3652
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3653 {
3654 37 showbombeddoor(dest, 3);
3655 37 }
3656 8166 }
3657
3658
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3659 {
3660
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3661 {
3662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3663 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3664 1123 }
3665 else
3666 {
3667
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3668 {
3669 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3670 48 int32_t tempitemx=-16;
3671 48 int32_t tempitemy=-16;
3672
3673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3674
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3675 {
3676 24 tempitemx=tmpscr->stairx;
3677 24 tempitemy=tmpscr->stairy+playing_field_offset;
3678 24 }
3679
3680 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3681 48 }
3682 }
3683 2034 }
3684 }
3685 16332 }
3686
3687 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3688
3689 7997 void draw_lens_over()
3690 {
3691 // Oh, what the heck.
3692 static BITMAP *lens_scr = NULL;
3693 static int32_t last_width = -1;
3694 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3695
3696 // Only redraw the circle if the size has changed
3697
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3698 {
3699
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3700 {
3701 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3702 5 }
3703
3704 5 clear_to_color(lens_scr, BLACK);
3705 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3706 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3707 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3708 5 last_width=width;
3709 5 }
3710
3711 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3712 7997 }
3713
3714 //----------------------------------------------------------------
3715
3716 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3717 {
3718 //recreating a big bitmap every frame is highly sluggish.
3719
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3720 30701 clear_to_color(wavebuf, BLACK);
3721 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3722
3723 int32_t ofs;
3724 // int32_t amplitude=8;
3725 // int32_t wavelength=4;
3726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3727
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3728 30701 int32_t amp2=168;
3729
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3730 30701 int32_t i=frame%amp2;
3731
3732
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3733 {
3734
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3735 {
3736 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3737 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3738 }
3739 else
3740 {
3741 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3742 }
3743
3744
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3745 {
3746
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3747 {
3748 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3749 1320388608 }
3750 5157768 }
3751 5157768 }
3752 30701 }
3753
3754 3312 void draw_fuzzy(int32_t fuzz)
3755 // draws from right half of scrollbuf to framebuf
3756 {
3757 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3758 byte *start, *si, *di;
3759
3760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3312 times.
3312 if(fuzz<1)
3761 fuzz = 1;
3762
3763 3312 xstep = 128%fuzz;
3764
3765
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 2622 times.
3312 if(xstep > 0)
3766 2622 xstep = fuzz-xstep;
3767
3768 3312 ystep = 112%fuzz;
3769
3770
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 2346 times.
3312 if(ystep > 0)
3771 2346 ystep = fuzz-ystep;
3772
3773 3312 firsty = 1;
3774
3775
2/2
✓ Branch 0 taken 3312 times.
✓ Branch 1 taken 119508 times.
122820 for(y=0; y<224;)
3776 {
3777 119508 start = &(scrollbuf->line[y][256]);
3778
3779
4/4
✓ Branch 0 taken 117852 times.
✓ Branch 1 taken 743544 times.
✓ Branch 2 taken 741888 times.
✓ Branch 3 taken 119508 times.
861396 for(dy=0; dy<ystep && dy+y<224; dy++)
3780 {
3781 741888 si = start;
3782 741888 di = &(framebuf->line[y+dy][0]);
3783 741888 i = xstep;
3784 741888 firstx = 1;
3785
3786
2/2
✓ Branch 0 taken 189923328 times.
✓ Branch 1 taken 741888 times.
190665216 for(dx=0; dx<256; dx++)
3787 {
3788 189923328 *(di++) = *si;
3789
3790
2/2
✓ Branch 0 taken 160031424 times.
✓ Branch 1 taken 29891904 times.
189923328 if(++i >= fuzz)
3791 {
3792
2/2
✓ Branch 0 taken 29150016 times.
✓ Branch 1 taken 741888 times.
29891904 if(!firstx)
3793 29150016 si += fuzz;
3794 else
3795 {
3796 741888 si += fuzz-xstep;
3797 741888 firstx = 0;
3798 }
3799
3800 29891904 i = 0;
3801 29891904 }
3802 189923328 }
3803 741888 }
3804
3805
2/2
✓ Branch 0 taken 116196 times.
✓ Branch 1 taken 3312 times.
119508 if(!firsty)
3806 116196 y += fuzz;
3807 else
3808 {
3809 3312 y += ystep;
3810 3312 ystep = fuzz;
3811 3312 firsty = 0;
3812 }
3813 }
3814 3312 }
3815
3816 7516513 void updatescr(bool allowwavy)
3817 {
3818
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7516482 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
7516513 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3819
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7516482 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
7516513 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3820
3821
2/2
✓ Branch 0 taken 7490809 times.
✓ Branch 1 taken 25704 times.
7516513 if(toogam)
3822 {
3823 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3824 25704 }
3825
3826
1/2
✓ Branch 0 taken 7516513 times.
✗ Branch 1 not taken.
7516513 if(Showpal)
3827 dump_pal(framebuf);
3828
3829
2/2
✓ Branch 0 taken 7422161 times.
✓ Branch 1 taken 94352 times.
7516513 if(!Playing)
3830 94352 black_opening_count=0;
3831
3832
2/2
✓ Branch 0 taken 7470181 times.
✓ Branch 1 taken 46332 times.
7516513 if(black_opening_count<0) //shape is opening up
3833 {
3834 46332 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3835
3836
2/4
✓ Branch 0 taken 46332 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46332 times.
46332 if(Advance||(!Paused))
3837 {
3838 46332 ++black_opening_count;
3839 46332 }
3840 46332 }
3841
2/2
✓ Branch 0 taken 7452031 times.
✓ Branch 1 taken 18150 times.
7470181 else if(black_opening_count>0) //shape is closing
3842 {
3843 18150 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3844
3845
2/4
✓ Branch 0 taken 18150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18150 times.
18150 if(Advance||(!Paused))
3846 {
3847 18150 --black_opening_count;
3848 18150 }
3849 18150 }
3850
3851
3/4
✓ Branch 0 taken 7453008 times.
✓ Branch 1 taken 63505 times.
✓ Branch 2 taken 7453008 times.
✗ Branch 3 not taken.
7516513 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3852 {
3853 black_opening_shape = bosCIRCLE;
3854 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3855 refreshTints();
3856 refreshpal=true;
3857 }
3858
3859
2/2
✓ Branch 0 taken 7300821 times.
✓ Branch 1 taken 215692 times.
7516513 if(refreshpal)
3860 {
3861 215692 refreshpal=false;
3862 215692 RAMpal[253] = _RGB(0,0,0);
3863 215692 RAMpal[254] = _RGB(63,63,63);
3864 215692 hw_palette = &RAMpal;
3865 215692 update_hw_pal = true;
3866
3867 215692 create_rgb_table(&rgb_table, RAMpal, NULL);
3868 215692 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3869 215692 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3870
3871
2/2
✓ Branch 0 taken 55217152 times.
✓ Branch 1 taken 215692 times.
55432844 for(int32_t q=0; q<PAL_SIZE; q++)
3872 {
3873 55217152 trans_table2.data[0][q] = q;
3874 55217152 trans_table2.data[q][q] = q;
3875 55217152 }
3876 215692 }
3877
3878 7516513 bool clearwavy = (wavy <= 0);
3879
3880
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 7509268 times.
7516513 if(wavy <= 0)
3881 {
3882 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3883 7509268 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3884 7509268 }
3885
3886 7516513 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3887
3888
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 7485562 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
7516513 if(wavy && Playing && allowwavy)
3889 {
3890 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3891 30701 }
3892
3893
2/2
✓ Branch 0 taken 7509268 times.
✓ Branch 1 taken 7245 times.
7516513 if(clearwavy)
3894 7509268 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3895
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3896 7245 wavy--; // Wavy was set by a script. Decrement it.
3897
3898
5/6
✓ Branch 0 taken 7422161 times.
✓ Branch 1 taken 94352 times.
✓ Branch 2 taken 170662 times.
✓ Branch 3 taken 7251499 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 170662 times.
7516513 if(Playing && msgpos && !screenscrolling)
3899 {
3900
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_bg_display_buf->clip))
3901 170662 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3902
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_portrait_display_buf->clip))
3903 170662 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3904
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_txt_display_buf->clip))
3905 170662 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3906 170662 }
3907
3908 /*
3909 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3910 {
3911 BITMAP* subBmp = 0;
3912 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3913 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3914 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3915 destroy_bitmap(subBmp);
3916 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3917 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3918 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3919 }
3920 */
3921
3922
2/2
✓ Branch 0 taken 7484192 times.
✓ Branch 1 taken 32321 times.
7516513 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3923
3924
2/2
✓ Branch 0 taken 7484192 times.
✓ Branch 1 taken 32321 times.
7516513 if(nosubscr)
3925 {
3926 32321 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3927 32321 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3928 32321 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3929 32321 }
3930
3931 //TODO: Optimize blit 'overcalls' -Gleeok
3932
2/2
✓ Branch 0 taken 32321 times.
✓ Branch 1 taken 7484192 times.
7516513 BITMAP *source = nosubscr ? panorama : wavybuf;
3933 7516513 blit(source,framebuf,0,0,0,0,256,224);
3934
3935 7516513 update_hw_screen();
3936 7516513 }
3937
3938 //----------------------------------------------------------------
3939
3940 PALETTE sys_pal;
3941
3942 int32_t onGUISnapshot()
3943 {
3944 char buf[200];
3945 int32_t num=0;
3946 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3947 do
3948 {
3949 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3950 }
3951 while(num<99999 && exists(buf));
3952
3953 BITMAP *b = create_bitmap_ex(8,resx,resy);
3954
3955 if(b)
3956 {
3957 if(MenuOpen)
3958 {
3959 //Cannot load game's palette while GUI elements are in focus. -Z
3960 //If there is a way to do this, then I have missed it.
3961 /*
3962 game_pal();
3963 RAMpal[253] = _RGB(0,0,0);
3964 RAMpal[254] = _RGB(63,63,63);
3965 zc_set_palette_range(RAMpal,0,255,false);
3966 memcpy(RAMpal, snappal, sizeof(snappal));
3967 create_rgb_table(&rgb_table, RAMpal, NULL);
3968 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3969 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3970
3971 for(int32_t q=0; q<PAL_SIZE; q++)
3972 {
3973 trans_table2.data[0][q] = q;
3974 trans_table2.data[q][q] = q;
3975 }
3976 */
3977 //ringcolor(false);
3978 //get_palette(RAMpal);
3979 blit(screen,b,0,0,0,0,resx,resy);
3980 //al_trace("Menu Open\n");
3981 //game_pal();
3982 //PALETTE temppal;
3983 //get_palette(temppal);
3984 //system_pal();
3985 save_bitmap(buf,b,sys_pal);
3986 //save_bitmap(buf,b,RAMpal);
3987 //save_bitmap(buf,b,snappal);
3988 }
3989 else
3990 {
3991 blit(screen,b,0,0,0,0,resx,resy);
3992 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3993 }
3994 destroy_bitmap(b);
3995 }
3996
3997 return D_O_K;
3998 }
3999
4000 int32_t onNonGUISnapshot()
4001 {
4002 PALETTE temppal;
4003 get_palette(temppal);
4004 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
4005
4006 char buf[200];
4007 int32_t num=0;
4008
4009 do
4010 {
4011 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4012 }
4013 while(num<99999 && exists(buf));
4014
4015 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
4016
4017 return D_O_K;
4018 }
4019
4020 int32_t onSnapshot()
4021 {
4022 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4023 {
4024 onGUISnapshot();
4025 }
4026 else
4027 {
4028 onNonGUISnapshot();
4029 }
4030
4031 return D_O_K;
4032 }
4033
4034 int32_t onSaveMapPic()
4035 {
4036 int32_t mapres2 = 0;
4037 char buf[200];
4038 int32_t num=0;
4039 mapscr tmpscr_b[2];
4040 mapscr tmpscr_c[6];
4041 BITMAP* _screen_draw_buffer = NULL;
4042 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4043 set_clip_state(_screen_draw_buffer,1);
4044
4045 for(int32_t i=0; i<6; ++i)
4046 {
4047 tmpscr_c[i] = tmpscr2[i];
4048 tmpscr2[i].zero_memory();
4049
4050 if(i>=2)
4051 {
4052 continue;
4053 }
4054
4055 tmpscr_b[i] = tmpscr[i];
4056 tmpscr[i].zero_memory();
4057 }
4058
4059 do
4060 {
4061 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4062 }
4063 while(num<99999 && exists(buf));
4064
4065 BITMAP* mappic = NULL;
4066
4067
4068 bool done=false, redraw=true;
4069
4070 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4071
4072 if(!mappic)
4073 {
4074 system_pal();
4075 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4076 game_pal();
4077 return D_O_K;;
4078 }
4079
4080 // draw the map
4081 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4082
4083 for(int32_t y=0; y<8; y++)
4084 {
4085 for(int32_t x=0; x<16; x++)
4086 {
4087 if(!displayOnMap(x, y))
4088 {
4089 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4090 }
4091 else
4092 {
4093 int32_t s = (y<<4) + x;
4094 loadscr2(1,s,-1);
4095
4096 for(int32_t i=0; i<6; i++)
4097 {
4098 if(tmpscr[1].layermap[i]<=0)
4099 continue;
4100
4101 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4102 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4103 {
4104 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4105
4106 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4107 }
4108 }
4109
4110 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4111
4112 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4113
4114 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4115 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4116
4117 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4118
4119 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4120 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4121 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4122 {
4123 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4124 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4125 }
4126 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4127
4128 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4129
4130 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4131 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4132 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4133 {
4134 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4135 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4136 }
4137 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4138 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4139
4140 }
4141
4142 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4143 }
4144 }
4145
4146 for(int32_t i=0; i<6; ++i)
4147 {
4148 tmpscr2[i]=tmpscr_c[i];
4149
4150 if(i>=2)
4151 {
4152 continue;
4153 }
4154
4155 tmpscr[i]=tmpscr_b[i];
4156 }
4157
4158 save_bitmap(buf,mappic,RAMpal);
4159 destroy_bitmap(mappic);
4160 destroy_bitmap(_screen_draw_buffer);
4161 return D_O_K;
4162 }
4163
4164 /*
4165 int32_t onSaveMapPic()
4166 {
4167 BITMAP* mappic = NULL;
4168 BITMAP* _screen_draw_buffer = NULL;
4169 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4170 int32_t mapres2 = 0;
4171 char buf[20];
4172 int32_t num=0;
4173 set_clip_state(_screen_draw_buffer,1);
4174 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4175
4176 do
4177 {
4178 sprintf(buf, "zelda%03d.png", ++num);
4179 }
4180 while(num<999 && exists(buf));
4181
4182 // if(!mappic) {
4183 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4184
4185 if(!mappic)
4186 {
4187 system_pal();
4188 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4189 game_pal();
4190 return D_O_K;
4191 }
4192
4193 // }
4194
4195 int32_t layermap, layerscreen;
4196 int32_t x2=0;
4197
4198 // draw the map
4199 for(int32_t y=0; y<8; y++)
4200 {
4201 for(int32_t x=0; x<16; x++)
4202 {
4203 int32_t s = (y<<4) + x;
4204
4205 if(!displayOnMap(x, y))
4206 {
4207 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4208 }
4209 else
4210 {
4211 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4212 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4213
4214 for(int32_t k=0; k<4; k++)
4215 {
4216 if(k==2)
4217 {
4218 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4219 }
4220
4221 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4222
4223 if(layermap>-1)
4224 {
4225 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4226
4227 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4228 {
4229 for(int32_t i=0; i<176; i++)
4230 {
4231 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4232 }
4233 }
4234 else
4235 {
4236 for(int32_t i=0; i<176; i++)
4237 {
4238 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4239 }
4240 }
4241 }
4242 }
4243
4244 for(int32_t i=0; i<176; i++)
4245 {
4246 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4247 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4248 {
4249 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4250 }
4251 }
4252
4253 for(int32_t k=4; k<6; k++)
4254 {
4255 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4256
4257 if(layermap>-1)
4258 {
4259 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4260
4261 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4262 {
4263 for(int32_t i=0; i<176; i++)
4264 {
4265 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4266 }
4267 }
4268 else
4269 {
4270 for(int32_t i=0; i<176; i++)
4271 {
4272 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4273 }
4274 }
4275 }
4276 }
4277 }
4278
4279 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4280 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4281 }
4282
4283 }
4284
4285 save_bitmap(buf,mappic,RAMpal);
4286 destroy_bitmap(mappic);
4287 destroy_bitmap(_screen_draw_buffer);
4288 return D_O_K;
4289 }
4290 */
4291
4292 13 void f_Quit(int32_t type)
4293 {
4294
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4295 return;
4296
4297 13 bool from_menu = is_sys_pal;
4298
4299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4300 {
4301 13 music_pause();
4302 13 pause_all_sfx();
4303 13 sys_mouse();
4304 13 }
4305 13 enter_sys_pal();
4306 13 clear_keybuf();
4307
4308
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (replay_is_active() && replay_get_version() <= 9)
4309 13 replay_poll();
4310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4311 13 replay_peek_quit();
4312
4313
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4314 switch(type)
4315 {
4316 case qQUIT:
4317 onQuit();
4318 break;
4319
4320 case qRESET:
4321 onReset();
4322 break;
4323
4324 case qEXIT:
4325 onExit();
4326 break;
4327 }
4328
4329
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4330 {
4331 13 kill_sfx();
4332 13 music_stop();
4333 13 exit_sys_pal();
4334 13 update_hw_screen();
4335 13 }
4336 else
4337 {
4338 exit_sys_pal();
4339 if(!from_menu)
4340 {
4341 music_resume();
4342 resume_all_sfx();
4343 }
4344 }
4345
4346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4347 13 game_mouse();
4348 13 eat_buttons();
4349
4350 13 zc_readrawkey(KEY_ESC);
4351
4352 13 zc_readrawkey(KEY_ENTER);
4353 13 }
4354
4355 //----------------------------------------------------------------
4356
4357 int32_t onNoWalls()
4358 {
4359 cheats_enqueue(Cheat::Walls);
4360 return D_O_K;
4361 }
4362
4363 int32_t onIgnoreSideview()
4364 {
4365 cheats_enqueue(Cheat::IgnoreSideView);
4366 return D_O_K;
4367 }
4368
4369 7516455 int32_t input_idle(bool checkmouse)
4370 {
4371 static int32_t mx, my, mz, mb;
4372
4373
4/6
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1926522 times.
✓ Branch 3 taken 5589933 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1926522 times.
9442977 if(keypressed() || zc_key_pressed() ||
4374
4/8
✓ Branch 0 taken 1926522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1926522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1926522 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1926522 times.
✗ Branch 7 not taken.
1926522 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4375 {
4376 5589933 idle_count = 0;
4377
4378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5589933 times.
5589933 if(active_count < MAX_ACTIVE)
4379 {
4380 5589933 ++active_count;
4381 5589933 }
4382 5589933 }
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1926522 times.
1926522 else if(idle_count < MAX_IDLE)
4384 {
4385 1926522 ++idle_count;
4386 1926522 active_count = 0;
4387 1926522 }
4388
4389 7516455 mx = mouse_x;
4390 7516455 my = mouse_y;
4391 7516455 mz = mouse_z;
4392 7516455 mb = mouse_b;
4393
4394 7516455 return idle_count;
4395 }
4396
4397 int32_t onGoFast()
4398 {
4399 cheats_enqueue(Cheat::Fast);
4400 return D_O_K;
4401 }
4402
4403 int32_t onKillCheat()
4404 {
4405 cheats_enqueue(Cheat::Kill);
4406 return D_O_K;
4407 }
4408
4409 int32_t onSecretsCheat()
4410 {
4411 cheats_enqueue(Cheat::TrigSecrets);
4412 return D_O_K;
4413 }
4414 int32_t onSecretsCheatPerm()
4415 {
4416 cheats_enqueue(Cheat::TrigSecretsPerm);
4417 return D_O_K;
4418 }
4419
4420 int32_t onShowLayer0()
4421 {
4422 show_layer_0 = !show_layer_0;
4423 return D_O_K;
4424 }
4425 int32_t onShowLayer1()
4426 {
4427 show_layer_1 = !show_layer_1;
4428 return D_O_K;
4429 }
4430 int32_t onShowLayer2()
4431 {
4432 show_layer_2 = !show_layer_2;
4433 return D_O_K;
4434 }
4435 int32_t onShowLayer3()
4436 {
4437 show_layer_3 = !show_layer_3;
4438 return D_O_K;
4439 }
4440 int32_t onShowLayer4()
4441 {
4442 show_layer_4 = !show_layer_4;
4443 return D_O_K;
4444 }
4445 int32_t onShowLayer5()
4446 {
4447 show_layer_5 = !show_layer_5;
4448 return D_O_K;
4449 }
4450 int32_t onShowLayer6()
4451 {
4452 show_layer_6 = !show_layer_6;
4453 return D_O_K;
4454 }
4455 int32_t onShowLayerO()
4456 {
4457 show_layer_over=!show_layer_over;
4458 return D_O_K;
4459 }
4460 int32_t onShowLayerP()
4461 {
4462 show_layer_push=!show_layer_push;
4463 return D_O_K;
4464 }
4465 int32_t onShowLayerS()
4466 {
4467 show_sprites=!show_sprites;
4468 return D_O_K;
4469 }
4470 int32_t onShowLayerF()
4471 {
4472 show_ffcs=!show_ffcs;
4473 return D_O_K;
4474 }
4475 int32_t onShowLayerW()
4476 {
4477 show_walkflags=!show_walkflags;
4478 if(show_walkflags)
4479 show_effectflags = false;
4480 return D_O_K;
4481 }
4482 int32_t onShowLayerE()
4483 {
4484 show_effectflags=!show_effectflags;
4485 if(show_effectflags)
4486 show_walkflags = false;
4487 return D_O_K;
4488 }
4489 int32_t onShowFFScripts()
4490 {
4491 show_ff_scripts=!show_ff_scripts;
4492 return D_O_K;
4493 }
4494 int32_t onShowHitboxes()
4495 {
4496 show_hitboxes=!show_hitboxes;
4497 return D_O_K;
4498 }
4499 int32_t onShowInfoOpacity()
4500 {
4501 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4502 zc_set_config("zc","debug_info_opacity",info_opacity);
4503 return D_O_K;
4504 }
4505
4506 int32_t onLightSwitch()
4507 {
4508 cheats_enqueue(Cheat::Light);
4509 return D_O_K;
4510 }
4511
4512 int32_t onGoTo();
4513 int32_t onGoToComplete();
4514
4515 7516455 void syskeys()
4516 {
4517 7516455 update_system_keys();
4518
4519 int32_t oldtitle_version;
4520
4521
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(close_button_quit)
4522 {
4523 close_button_quit=false;
4524 f_Quit(qEXIT);
4525 }
4526
4527 7516455 poll_joystick();
4528
4529
2/10
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7516455 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7516455 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4530 {
4531 oldtitle_version=title_version;
4532 System();
4533 }
4534
4535 7516455 mouse_down=gui_mouse_b();
4536
4537
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(zc_read_system_key(KEY_F1))
4538 {
4539 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4540 {
4541 halt=!halt;
4542 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4543 }
4544 else
4545 {
4546 Throttlefps=!Throttlefps;
4547 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4548 logic_counter=0;
4549 }
4550 }
4551
4552 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4553 /*
4554 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4555 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4556 */
4557
4558
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(zc_read_system_key(KEY_F2))
4559 {
4560 ShowFPS=!ShowFPS;
4561 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4562 }
4563
4564
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7516455 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4565
4566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7516455 if(zc_read_system_key(KEY_F4) && Playing)
4567 {
4568 Paused=true;
4569 Advance=true;
4570 }
4571
4572
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(zc_read_system_key(KEY_F6)) onTryQuit();
4573
4574 #ifndef ALLEGRO_MACOSX
4575
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4576
4577
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4578 #else
4579 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4580
4581 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4582 #endif
4583
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7516455 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4584
4585
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if (zc_read_system_key(KEY_F12))
4586 {
4587 onSnapshot();
4588 }
4589
4590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7516455 if(debug_enabled && zc_read_system_key(KEY_TAB))
4591 set_debug(!get_debug());
4592
4593
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(CheatModifierKeys())
4594 {
4595 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4596 {
4597 if(!bindable_cheat(c))
4598 continue;
4599 if(get_debug() || cheat >= cheat_lvl(c))
4600 {
4601 if(checkcheat(c))
4602 cheats_hit_bind(c);
4603 }
4604 }
4605 }
4606
4607
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(volkeys)
4608 {
4609 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4610
4611 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4612
4613 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4614
4615 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4616 }
4617
4618
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7516455 if(!get_debug() || !SystemKeys || replay_is_replaying())
4619 7516455 goto bottom;
4620
4621 if(zc_readkey(KEY_D))
4622 {
4623 details = !details;
4624 rectfill(screen,0,0,319,7,BLACK);
4625 rectfill(screen,0,8,31,239,BLACK);
4626 rectfill(screen,288,8,319,239,BLACK);
4627 rectfill(screen,32,232,287,239,BLACK);
4628 }
4629
4630 if(zc_readkey(KEY_P)) Paused=!Paused;
4631
4632 //if(zc_readkey(KEY_P)) centerHero();
4633 if(zc_readkey(KEY_A))
4634 {
4635 Paused=true;
4636 Advance=true;
4637 }
4638
4639 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4640 #ifndef ALLEGRO_MACOSX
4641 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4642
4643 if(zc_readkey(KEY_F7))
4644 {
4645 Matrix(ss_speed, ss_density, 0);
4646 game_pal();
4647 }
4648 #else
4649 // The reason these are different on Mac in the first place is that
4650 // the OS doesn't let us use F9 and F10...
4651 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4652
4653 if(zc_readkey(KEY_F9))
4654 {
4655 Matrix(ss_speed, ss_density, 0);
4656 game_pal();
4657 }
4658 #endif
4659 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4660 {
4661 //change containers
4662 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4663 {
4664 //magic containers
4665 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4666 {
4667 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4668 }
4669 else
4670 {
4671 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4672 }
4673 }
4674 else
4675 {
4676 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4677 {
4678 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4679 }
4680 else
4681 {
4682 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4683 }
4684 }
4685 }
4686
4687 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4688 {
4689 //change containers
4690 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4691 {
4692 //magic containers
4693 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4694 {
4695 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4696 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4697 //heart containers
4698 }
4699 else
4700 {
4701 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4702 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4703 }
4704 }
4705 else
4706 {
4707 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4708 {
4709 game->set_magic(zc_max(game->get_magic()-1,0));
4710 }
4711 else
4712 {
4713 game->set_life(zc_max(game->get_life()-1,0));
4714 }
4715 }
4716 }
4717
4718 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4719
4720 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4721
4722 verifyBothWeapons();
4723
4724 bottom:
4725
4726
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(input_idle(true) > after_time())
4727 {
4728 Matrix(ss_speed, ss_density, 0);
4729 game_pal();
4730 }
4731 7516455 }
4732
4733 329854 void checkQuitKeys()
4734 {
4735 #ifndef ALLEGRO_MACOSX
4736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 329854 times.
329854 if(key[KEY_F9]) f_Quit(qRESET);
4737
4738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 329854 times.
329854 if(key[KEY_F10]) f_Quit(qEXIT);
4739 #else
4740 if(key[KEY_F7]) f_Quit(qRESET);
4741
4742 if(key[KEY_F8]) f_Quit(qEXIT);
4743 #endif
4744 329854 }
4745
4746 7516455 bool CheatModifierKeys()
4747 {
4748 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4749 // to trigger cheats.
4750
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if (replay_is_replaying())
4751 7516455 return false;
4752
4753 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4754 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4755 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4756 {
4757 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4758 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4759 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4760 {
4761 return true;
4762 }
4763 }
4764 return false;
4765 7516455 }
4766
4767 //99:05:54, for some reason?
4768 #define OLDMAXTIME 21405240
4769 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4770 #define MAXTIME 1944000000
4771
4772 7516513 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4773 {
4774
2/2
✓ Branch 0 taken 7238172 times.
✓ Branch 1 taken 278341 times.
7516513 if(zcmusic!=NULL)
4775 {
4776 278341 zcmusic_poll();
4777 278341 }
4778
4779 7516513 updatescr(allowwavy);
4780
4781 7516513 Advance=false;
4782
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7516513 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7516513 times.
7516513 while(Paused && !Advance && !Quit)
4783 {
4784 // have to call this, otherwise we'll get an infinite loop
4785 syskeys();
4786 if(allowF6Script)
4787 {
4788 FFCore.runF6Engine();
4789 }
4790 throttleFPS();
4791
4792 #ifdef _WIN32
4793
4794 if(use_dwm_flush)
4795 {
4796 do_DwmFlush();
4797 }
4798
4799 #endif
4800
4801 // to keep music playing
4802 if(zcmusic!=NULL)
4803 {
4804 zcmusic_poll();
4805 }
4806
4807 update_hw_screen();
4808 }
4809
4810
2/2
✓ Branch 0 taken 7516466 times.
✓ Branch 1 taken 47 times.
7516513 if(Quit)
4811 47 return;
4812
4813
3/4
✓ Branch 0 taken 7422152 times.
✓ Branch 1 taken 94314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7422152 times.
7516466 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4814 7422152 game->change_time(1);
4815
4816
3/4
✓ Branch 0 taken 7516466 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011251 times.
✓ Branch 3 taken 6505215 times.
7516466 if (!replay_is_active() || replay_get_version() >= 11)
4817
2/2
✓ Branch 0 taken 18202518 times.
✓ Branch 1 taken 1011251 times.
19213769 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4818 19213769 down_control_states[i] = raw_control_state[i];
4819
4820
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7516465 times.
7516466 if (replay_is_active())
4821 {
4822
2/2
✓ Branch 0 taken 1270462 times.
✓ Branch 1 taken 6246003 times.
7516465 if (replay_get_version() >= 3)
4823 6246003 replay_poll();
4824
4825
6/6
✓ Branch 0 taken 6505205 times.
✓ Branch 1 taken 1011250 times.
✓ Branch 2 taken 3084553 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2984018 times.
7516465 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4826 1111785 replay_peek_input();
4827 7516455 }
4828
4829 7516466 load_control_called_this_frame = false;
4830
4831 7516466 poll_keyboard();
4832 7516466 update_keys();
4833
4834 7516466 ++frame;
4835
4836
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7516455 times.
7516466 if (replay_is_replaying())
4837 7516455 replay_do_cheats();
4838 7516466 syskeys();
4839
4840 // The mouse variables can change from the mouse thread at anytime during a frame,
4841 // so save the result at the start so that replaying is consistent.
4842 7516466 script_mouse_x = gui_mouse_x();
4843 7516466 script_mouse_y = gui_mouse_y();
4844 7516466 script_mouse_z = mouse_z;
4845 7516466 script_mouse_b = mouse_b;
4846
4847 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4848 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4849 // approach here means it doesn't matter which call adds the cheat.
4850 7516466 cheats_execute_queued();
4851
4852
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7516455 times.
7516466 if (replay_is_replaying())
4853 7516455 replay_peek_quit();
4854
2/2
✓ Branch 0 taken 7516453 times.
✓ Branch 1 taken 13 times.
7516466 if (GameFlags & GAMEFLAG_TRYQUIT)
4855 13 replay_step_quit(0);
4856
2/2
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 7514265 times.
7516466 if(allowF6Script)
4857 7514265 FFCore.runF6Engine();
4858
2/2
✓ Branch 0 taken 7516278 times.
✓ Branch 1 taken 188 times.
7516466 if (Quit)
4859 188 replay_step_quit(Quit);
4860 // Someday... maybe install a Turbo button here?
4861 7516466 throttleFPS();
4862
4863 #ifdef _WIN32
4864
4865 if(use_dwm_flush)
4866 {
4867 do_DwmFlush();
4868 }
4869
4870 #endif
4871
4872 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4873
2/2
✓ Branch 0 taken 40867 times.
✓ Branch 1 taken 7475599 times.
7516466 if(sfxcleanup)
4874 7475599 sfx_cleanup();
4875 7516513 }
4876
4877 69 void zapout()
4878 {
4879 69 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4880 69 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4881
4882 69 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4883 69 script_drawing_commands.Clear();
4884
4885 // zap out
4886
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1656 times.
1725 for(int32_t i=1; i<=24; i++)
4887 {
4888 1656 draw_fuzzy(i);
4889 1656 advanceframe(true);
4890
4891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
1656 if(Quit)
4892 {
4893 break;
4894 }
4895 1656 }
4896 69 }
4897
4898 69 void zapin()
4899 {
4900 69 FFCore.warpScriptCheck();
4901 69 draw_screen(tmpscr);
4902 69 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4903 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4904 69 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4905
4906 // zap out
4907 69 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4908
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1656 times.
1725 for(int32_t i=24; i>=1; i--)
4909 {
4910 1656 draw_fuzzy(i);
4911 1656 advanceframe(true);
4912
4913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
1656 if(Quit)
4914 {
4915 break;
4916 }
4917 1656 }
4918 69 }
4919
4920
4921 32 void wavyout(bool showhero)
4922 {
4923 32 draw_screen(tmpscr, showhero);
4924 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4925
4926 32 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4927 32 clear_to_color(wavebuf,0);
4928 32 blit(framebuf,wavebuf,0,0,16,0,256,224);
4929
4930 static PALETTE wavepal;
4931
4932 int32_t ofs;
4933 32 int32_t amplitude=8;
4934
4935 32 int32_t wavelength=4;
4936 32 double palpos=0, palstep=4, palstop=126;
4937
4938 32 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4939
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1344 times.
1376 for(int32_t i=0; i<168; i+=wavelength)
4940 {
4941
2/2
✓ Branch 0 taken 344064 times.
✓ Branch 1 taken 1344 times.
345408 for(int32_t l=0; l<256; l++)
4942 {
4943 344064 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4944 344064 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4945 344064 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4946 344064 }
4947
4948 1344 palpos+=palstep;
4949
4950
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(palpos>=0)
4951 {
4952 1344 hw_palette = &wavepal;
4953 1344 update_hw_pal = true;
4954 1344 }
4955 else
4956 {
4957 hw_palette = &RAMpal;
4958 update_hw_pal = true;
4959 }
4960
4961
2/2
✓ Branch 0 taken 225792 times.
✓ Branch 1 taken 1344 times.
227136 for(int32_t j=0; j+playing_field_offset<224; j++)
4962 {
4963
2/2
✓ Branch 0 taken 57802752 times.
✓ Branch 1 taken 225792 times.
58028544 for(int32_t k=0; k<256; k++)
4964 {
4965 57802752 ofs=0;
4966
4967
4/4
✓ Branch 0 taken 28213248 times.
✓ Branch 1 taken 29589504 times.
✓ Branch 2 taken 14106624 times.
✓ Branch 3 taken 14106624 times.
57802752 if((j<i)&&(j&1))
4968 {
4969 14106624 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4970 14106624 }
4971
4972 57802752 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4973 57802752 }
4974 225792 }
4975
4976 1344 advanceframe(true);
4977
4978 // animate_combos();
4979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
1344 if(Quit)
4980 break;
4981 1344 }
4982
4983 32 destroy_bitmap(wavebuf);
4984 32 }
4985
4986 32 void wavyin()
4987 {
4988 32 draw_screen(tmpscr);
4989 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4990
4991 32 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4992 32 clear_to_color(wavebuf,0);
4993 32 blit(framebuf,wavebuf,0,0,16,0,256,224);
4994
4995 static PALETTE wavepal;
4996
4997 //Breaks dark rooms.
4998 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4999 /*
5000 loadfullpal();
5001 loadlvlpal(DMaps[currdmap].color);
5002 ringcolor(false);
5003 */
5004 32 refreshpal=false;
5005 int32_t ofs;
5006 32 int32_t amplitude=8;
5007 32 int32_t wavelength=4;
5008 32 double palpos=168, palstep=4, palstop=126;
5009
5010 32 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5011
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1344 times.
1376 for(int32_t i=0; i<168; i+=wavelength)
5012 {
5013
2/2
✓ Branch 0 taken 344064 times.
✓ Branch 1 taken 1344 times.
345408 for(int32_t l=0; l<256; l++)
5014 {
5015 344064 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5016 344064 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5017 344064 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5018 344064 }
5019
5020 1344 palpos-=palstep;
5021
5022
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(palpos>=0)
5023 {
5024 1344 hw_palette = &wavepal;
5025 1344 update_hw_pal = true;
5026 1344 }
5027 else
5028 {
5029 hw_palette = &RAMpal;
5030 update_hw_pal = true;
5031 }
5032
5033
2/2
✓ Branch 0 taken 225792 times.
✓ Branch 1 taken 1344 times.
227136 for(int32_t j=0; j+playing_field_offset<224; j++)
5034 {
5035
2/2
✓ Branch 0 taken 57802752 times.
✓ Branch 1 taken 225792 times.
58028544 for(int32_t k=0; k<256; k++)
5036 {
5037 57802752 ofs=0;
5038
5039
4/4
✓ Branch 0 taken 29245440 times.
✓ Branch 1 taken 28557312 times.
✓ Branch 2 taken 14794752 times.
✓ Branch 3 taken 14450688 times.
57802752 if((j<(167-i))&&(j&1))
5040 {
5041 14450688 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5042 14450688 }
5043
5044 57802752 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5045 57802752 }
5046 225792 }
5047
5048 1344 advanceframe(true);
5049 // animate_combos();
5050
5051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
1344 if(Quit)
5052 break;
5053 1344 }
5054
5055 32 destroy_bitmap(wavebuf);
5056 32 }
5057
5058 1825 void blackscr(int32_t fcnt,bool showsubscr)
5059 {
5060 1825 reset_pal_cycling();
5061 1825 script_drawing_commands.Clear();
5062
5063 1825 FFCore.warpScriptCheck();
5064 1825 bool showtime = game->should_show_time();
5065
2/2
✓ Branch 0 taken 1825 times.
✓ Branch 1 taken 54680 times.
56505 while(fcnt>0)
5066 {
5067 54680 clear_bitmap(framebuf);
5068
5069
2/2
✓ Branch 0 taken 17460 times.
✓ Branch 1 taken 37220 times.
54680 if(showsubscr)
5070 {
5071 37220 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5072
3/4
✓ Branch 0 taken 37220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 36470 times.
37220 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5073 {
5074 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5075 750 }
5076 37220 }
5077
5078 54680 advanceframe(true);
5079
5080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54680 times.
54680 if(Quit)
5081 break;
5082
5083 54680 --fcnt;
5084 }
5085 1825 }
5086
5087 644 void openscreen(int32_t shape)
5088 {
5089 644 reset_pal_cycling();
5090 644 black_opening_count=0;
5091
5092
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
644 if(COOLSCROLL || shape>-1)
5093 {
5094 546 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5095 546 return;
5096 }
5097 else
5098 {
5099 98 Hero.setDontDraw(true);
5100 98 show_subscreen_dmap_dots=false;
5101 98 show_subscreen_numbers=false;
5102 // show_subscreen_items=false;
5103 98 show_subscreen_life=false;
5104 }
5105
5106 98 int32_t x=128;
5107
5108 98 FFCore.warpScriptCheck();
5109
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5110 {
5111 7840 draw_screen(tmpscr);
5112 //? draw_screen already draws the subscreen -DD
5113 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5114 7840 x=128-(((i*128/80)/8)*8);
5115
5116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5117 {
5118 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5119 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5120 7840 }
5121
5122 7840 advanceframe(true);
5123
5124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5125 {
5126 break;
5127 }
5128 7840 }
5129
5130 98 Hero.setDontDraw(false);
5131 98 show_subscreen_items=true;
5132 98 show_subscreen_dmap_dots=true;
5133 644 }
5134
5135 void closescreen(int32_t shape)
5136 {
5137 reset_pal_cycling();
5138 black_opening_count=0;
5139
5140 if(COOLSCROLL || shape>-1)
5141 {
5142 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5143 return;
5144 }
5145 else
5146 {
5147 Hero.setDontDraw(true);
5148 show_subscreen_dmap_dots=false;
5149 show_subscreen_numbers=false;
5150 // show_subscreen_items=false;
5151 show_subscreen_life=false;
5152 }
5153
5154 int32_t x=128;
5155
5156 FFCore.warpScriptCheck();
5157 for(int32_t i=79; i>=0; --i)
5158 {
5159 draw_screen(tmpscr);
5160 //? draw_screen already draws the subscreen -DD
5161 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5162 x=128-(((i*128/80)/8)*8);
5163
5164 if(x>0)
5165 {
5166 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5167 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5168 }
5169
5170 advanceframe(true);
5171
5172 if(Quit)
5173 {
5174 break;
5175 }
5176 }
5177
5178 Hero.setDontDraw(false);
5179 show_subscreen_items=true;
5180 show_subscreen_dmap_dots=true;
5181 }
5182
5183 175 int32_t TriforceCount()
5184 {
5185 175 int32_t c=0;
5186
5187
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 175 times.
1575 for(int32_t i=1; i<=8; i++)
5188
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1016 times.
2416 if(game->lvlitems[i]&liTRIFORCE)
5189 1016 ++c;
5190
5191 175 return c;
5192 }
5193
5194 int32_t onCustomGame()
5195 {
5196 int32_t file = getsaveslot();
5197
5198 if(file < 0)
5199 return D_O_K;
5200
5201 bool ret = (custom_game(file)!=0);
5202 return ret ? D_CLOSE : D_O_K;
5203 }
5204
5205 int32_t onContinue()
5206 {
5207 return D_CLOSE;
5208 }
5209
5210 int32_t onEsc() // Unused?? -L
5211 {
5212 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5213 }
5214
5215 int32_t onVsync()
5216 {
5217 Throttlefps = !Throttlefps;
5218 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5219 return D_O_K;
5220 }
5221
5222 int32_t onWinPosSave()
5223 {
5224 SaveWinPos = !SaveWinPos;
5225 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5226 return D_O_K;
5227 }
5228 int32_t onIntegerScaling()
5229 {
5230 scaleForceInteger = !scaleForceInteger;
5231 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5232 return D_O_K;
5233 }
5234 int32_t onStretchGame()
5235 {
5236 stretchGame = !stretchGame;
5237 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5238 return D_O_K;
5239 }
5240
5241 int32_t onClickToFreeze()
5242 {
5243 ClickToFreeze = !ClickToFreeze;
5244 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5245 return D_O_K;
5246 }
5247
5248 int32_t OnSaveZCConfig()
5249 {
5250 if(jwin_alert3(
5251 "Save Configuration",
5252 "Are you sure that you wish to save your present configuration settings?",
5253 "This will overwrite your prior settings!",
5254 NULL,
5255 "&Yes",
5256 "&No",
5257 NULL,
5258 'y',
5259 'n',
5260 0,
5261 get_zc_font(font_lfont)) == 1)
5262 {
5263 save_game_configs();
5264 return D_O_K;
5265 }
5266 else return D_O_K;
5267 }
5268
5269 int32_t OnnClearQuestDir()
5270 {
5271 if(jwin_alert3(
5272 "Clear Current Directory Cache",
5273 "Are you sure that you wish to clear the current cached directory?",
5274 "This will default the current directory to the ROOT for this instance of ZC Player!",
5275 NULL,
5276 "&Yes",
5277 "&No",
5278 NULL,
5279 'y',
5280 'n',
5281 0,
5282 get_zc_font(font_lfont)) == 1)
5283 {
5284 zc_set_config("zeldadx","win_qst_dir","");
5285 flush_config_file();
5286 strcpy(qstdir,"");
5287 #ifdef __EMSCRIPTEN__
5288 em_sync_fs();
5289 #endif
5290 return D_O_K;
5291 }
5292 else return D_O_K;
5293 }
5294
5295
5296 int32_t onConsoleZASM()
5297 {
5298 if ( !zasm_debugger )
5299 {
5300 AlertDialog("WARNING: ZASM Debugger",
5301 "Enabling this will open the ZASM Debugger Console"
5302 "\nThis will likely grind ZC to a halt with lag."
5303 "\nTo make any use of this, it is suggested that you read"
5304 "\nthe documentation for 'void Breakpoint(char[] string);'"
5305 " in 'ZScript_Additions.txt'"
5306 "\nThis is not recommended for normal users,"
5307 " and is only intended for ZC developers,"
5308 "\nor quest developers coding directly in ZASM"
5309 "\nAre you sure that you wish to open the ZASM Debugger?",
5310 [&](bool ret,bool)
5311 {
5312 if(ret)
5313 {
5314 FFCore.ZASMPrint(true);
5315 }
5316 }).show();
5317 return D_O_K;
5318 }
5319 else
5320 {
5321 FFCore.ZASMPrint(false);
5322 return D_O_K;
5323 }
5324 }
5325
5326
5327 int32_t onConsoleZScript()
5328 {
5329 if ( !zscript_debugger )
5330 {
5331 AlertDialog("ZScript Debugger",
5332 "Enabling this will open the ZScript Debugger Console"
5333 "\nThis will display any messages logged by scripts,"
5334 " including script errors."
5335 "\nAre you sure that you wish to open the ZScript Debugger?",
5336 [&](bool ret,bool)
5337 {
5338 if(ret)
5339 {
5340 FFCore.ZScriptConsole(true);
5341 }
5342 }).show();
5343 return D_O_K;
5344 }
5345 else
5346 {
5347 FFCore.ZScriptConsole(false);
5348 return D_O_K;
5349 }
5350 }
5351
5352 int32_t onClrConsoleOnReload()
5353 {
5354 clearConsoleOnReload = !clearConsoleOnReload;
5355 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5356 return D_O_K;
5357 }
5358 int32_t onClrConsoleOnLoad()
5359 {
5360 clearConsoleOnLoad = !clearConsoleOnLoad;
5361 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5362 return D_O_K;
5363 }
5364
5365
5366 int32_t onFrameSkip()
5367 {
5368 FrameSkip = !FrameSkip;
5369 return D_O_K;
5370 }
5371
5372 int32_t onSaveDragResize()
5373 {
5374 SaveDragResize = !SaveDragResize;
5375 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5376 return D_O_K;
5377 }
5378
5379 int32_t onDragAspect()
5380 {
5381 DragAspect = !DragAspect;
5382 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5383 return D_O_K;
5384 }
5385
5386 int32_t onTransLayers()
5387 {
5388 TransLayers = !TransLayers;
5389 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5390 return D_O_K;
5391 }
5392
5393 int32_t onNESquit()
5394 {
5395 NESquit = !NESquit;
5396 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5397 return D_O_K;
5398 }
5399
5400 int32_t onVolKeys()
5401 {
5402 volkeys = !volkeys;
5403 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5404 return D_O_K;
5405 }
5406
5407 int32_t onShowFPS()
5408 {
5409 ShowFPS = !ShowFPS;
5410 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5411 return D_O_K;
5412 }
5413
5414 886941690 bool is_Fkey(int32_t k)
5415 {
5416
2/2
✓ Branch 0 taken 90197460 times.
✓ Branch 1 taken 796744230 times.
886941690 switch(k)
5417 {
5418 case KEY_F1:
5419 case KEY_F2:
5420 case KEY_F3:
5421 case KEY_F4:
5422 case KEY_F5:
5423 case KEY_F6:
5424 case KEY_F7:
5425 case KEY_F8:
5426 case KEY_F9:
5427 case KEY_F10:
5428 case KEY_F11:
5429 case KEY_F12:
5430 90197460 return true;
5431 }
5432
5433 796744230 return false;
5434 886941690 }
5435
5436 void kb_getkey(DIALOG *d);
5437
5438 //Used by all keyboard key settings dialogues.
5439 void kb_clearjoystick(DIALOG *d)
5440 {
5441 d->flags|=D_SELECTED;
5442
5443 jwin_button_proc(MSG_DRAW,d,0);
5444 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5445 // text_mode(vc(11));
5446 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5447 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5448
5449 update_hw_screen(true);
5450
5451 clear_keybuf();
5452 int32_t k = next_press_key();
5453 clear_keybuf();
5454
5455 //shnarf
5456 //47=f1
5457 //59=esc
5458 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5459 // *((int32_t*)d->dp3) = k;
5460 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5461
5462
5463 d->flags&=~D_SELECTED;
5464 }
5465
5466 //Clears key to 0.
5467 //Used by all keyboard key settings dialogues.
5468 void kb_clearkey(DIALOG *d);
5469
5470 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5471 {
5472 switch(msg)
5473 {
5474 case MSG_KEY:
5475 case MSG_CLICK:
5476
5477 kb_clearjoystick(d);
5478
5479 while(gui_mouse_b())
5480 {
5481 clear_keybuf();
5482 rest(1);
5483 }
5484
5485 return D_REDRAW;
5486 }
5487
5488 return jwin_button_proc(msg,d,c);
5489 }
5490
5491 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5492 //Only used in keyboard settings dialogues to clear keys.
5493 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5494
5495 void j_getbtn(DIALOG *d)
5496 {
5497 d->flags|=D_SELECTED;
5498 jwin_button_proc(MSG_DRAW,d,0);
5499 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5500 // text_mode(vc(11));
5501 int32_t y = gui_bmp->h/2 - 12;
5502 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5503 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5504 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5505
5506 update_hw_screen(true);
5507
5508 int32_t b = next_press_btn();
5509
5510 if(b>=0)
5511 *((int32_t*)d->dp3) = b;
5512
5513 d->flags&=~D_SELECTED;
5514
5515 if (player)
5516 player->joy_on = TRUE;
5517 }
5518
5519 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5520 {
5521 switch(msg)
5522 {
5523 case MSG_KEY:
5524 case MSG_CLICK:
5525
5526 j_getbtn(d);
5527
5528 while(gui_mouse_b()) {
5529 rest(1);
5530 clear_keybuf();
5531 }
5532
5533 return D_REDRAW;
5534 }
5535
5536 return jwin_button_proc(msg,d,c);
5537 }
5538
5539 //shnarf
5540 extern const char *key_str[];
5541 std::string get_keystr(int key);
5542
5543 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5544 //extern int32_t zcmusic_bufsz;
5545
5546 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5547 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5548
5549 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5550 {
5551 //these are here to bypass compiler warnings about unused arguments
5552 c=c;
5553
5554 if(msg==MSG_DRAW)
5555 {
5556 switch(d->w)
5557 {
5558 case 0:
5559 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5560 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5561 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5562 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5563 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5564 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5565 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5566 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5567 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5568 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5569 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5570 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5571 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5572 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5573 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5574 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5575 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5576 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5577 break;
5578
5579 case 1:
5580 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5581 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5582 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5583 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5584 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5585 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5586 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5587 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5588 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5589 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5590 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5591 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5592 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5593 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5594 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5595 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5596 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5597 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5598 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5599 break;
5600
5601 case 2:
5602 sprintf(str_a," %3d",midi_volume);
5603 sprintf(str_b," %3d",digi_volume);
5604 sprintf(str_l," %3d",emusic_volume);
5605 sprintf(str_m," %3dKB",zcmusic_bufsz);
5606 sprintf(str_r," %3d",sfx_volume);
5607 strcpy(str_s,pan_str[pan_style]);
5608 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5609 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5610 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5611 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5612 break;
5613 }
5614 }
5615
5616 return D_O_K;
5617 }
5618
5619 int32_t set_vol(void *dp3, int32_t d2)
5620 {
5621 switch(((int32_t*)dp3)[0])
5622 {
5623 case 0:
5624 midi_volume = zc_min(d2<<3,255);
5625 break;
5626
5627 case 1:
5628 digi_volume = zc_min(d2<<3,255);
5629 break;
5630
5631 case 2:
5632 emusic_volume = zc_min(d2<<3,255);
5633 break;
5634
5635 case 3:
5636 sfx_volume = zc_min(d2<<3,255);
5637 break;
5638 }
5639
5640 // text_mode(vc(11));
5641 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5642 return D_O_K;
5643 }
5644
5645 int32_t set_pan(void *dp3, int32_t d2)
5646 {
5647 pan_style = vbound(d2,0,3);
5648 // text_mode(vc(11));
5649 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5650 return D_O_K;
5651 }
5652
5653 int32_t set_buf(void *dp3, int32_t d2)
5654 {
5655 // text_mode(vc(11));
5656 zcmusic_bufsz = d2 + 1;
5657 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5658 return D_O_K;
5659 }
5660
5661 static int32_t gamepad_btn_list[] =
5662 {
5663 6,
5664 7,8,9,10,11,12,13,14,15,16,17,
5665 18,19,20,21,22,23,24,25,26,27,28,
5666 29,30,31,32,33,34,35,36,37,38,39,
5667 -1
5668 };
5669
5670 static int32_t gamepad_dirs_list[] =
5671 {
5672 40,41,42,43,
5673 44,45,46,47,
5674 48,49,50,51,
5675 52,53,54,55,
5676 56,
5677 -1
5678 };
5679
5680 static TABPANEL gamepad_tabs[] =
5681 {
5682 // (text)
5683 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5684 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5685 { NULL, 0, NULL, 0, NULL }
5686 };
5687
5688 static DIALOG gamepad_dlg[] =
5689 {
5690 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5691 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5692 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5693 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5694 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5695 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5696 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5697 // 6
5698 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5699 // 7
5700 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5701 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5702 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5703 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5704 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5705 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5706 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5707 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5708 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5709 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5710 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5711 // 18
5712 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5713 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5714 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5715 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5716 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5717 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5718 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5719 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5720 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5721 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5722 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5723 // 29
5724 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5725 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5726 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5727 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5728 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5729 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5730 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5731 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5732 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5733 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5734 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5735 // 40
5736 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5737 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5738 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5739 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5740 // 44
5741 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5742 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5743 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5744 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5745 // 48
5746 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5747 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5748 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5749 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5750 // 52
5751 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5752 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5753 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5754 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5755 // 56
5756 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5757 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5758 };
5759
5760 static int32_t keyboard_keys_list[] =
5761 {
5762 6,7,8,9,10,
5763 11,12,13,14,15,16,17,18,19,20,
5764 21,22,23,24,25,26,27,28,29,30,
5765 31,32,33,34,35,36,37,38,39,40,
5766 -1
5767 };
5768
5769 static int32_t keyboard_dirs_list[] =
5770 {
5771 41,42,43,44,
5772 45,46,47,48,
5773 49,50,51,52,
5774 53,54,55,56,
5775 -1
5776 };
5777
5778 static int32_t keyboard_mods_list[] =
5779 {
5780 57,58,59,60,
5781 61,62,63,64,
5782 65,66,67,68,
5783 69,70,71,72,
5784 -1
5785 };
5786
5787 static TABPANEL keyboard_control_tabs[] =
5788 {
5789 // (text)
5790 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5791 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5792 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5793 { NULL, 0, NULL, 0, NULL }
5794 };
5795
5796 static DIALOG keyboard_control_dlg[] =
5797 {
5798 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5799 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5800 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5801 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5802 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5803 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5804 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5805 // Keys
5806 // 6
5807 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5808 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5809 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5810 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5811 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5812 // 11
5813 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5814 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5815 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5816 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5817 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5818 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5819 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5820 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5821 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5822 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5823 // 21
5824 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5825 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5826 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5827 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5828 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5829 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5830 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5831 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5832 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5833 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5834 // 31
5835 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5836 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5837 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5838 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5839 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5840 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5841 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5842 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5843 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5844 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5845 // Dirs
5846 // 41
5847 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5848 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5849 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5850 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5851 // 45
5852 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5853 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5854 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5855 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5856 // 49
5857 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5858 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5859 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5860 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5861 // 53
5862 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5863 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5864 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5865 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5866 // Mods
5867 // 57
5868 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5869 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5870 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5871 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5872 // 61
5873 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5874 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5875 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5876 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5877 // 65
5878 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5879 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5880 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5881 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5882 // 69
5883 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5884 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5885 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5886 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5887 // 73
5888 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5889 };
5890
5891 /*
5892 int32_t midi_dp[3] = {0,147,104};
5893 int32_t digi_dp[3] = {1,147,120};
5894 int32_t pan_dp[3] = {0,147,136};
5895 int32_t buf_dp[3] = {0,147,152};
5896 */
5897 int32_t midi_dp[3] = {0,0,0};
5898 int32_t digi_dp[3] = {1,0,0};
5899 int32_t emus_dp[3] = {2,0,0};
5900 int32_t buf_dp[3] = {0,0,0};
5901 int32_t sfx_dp[3] = {3,0,0};
5902 int32_t pan_dp[3] = {0,0,0};
5903
5904 static DIALOG sound_dlg[] =
5905 {
5906 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5907 31 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5908 31 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5909 31 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5910 31 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5911 31 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5912 31 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5913 31 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5914 31 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5915 31 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5916 31 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5917 // 10
5918 31 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5919 31 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5920 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5921 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5922 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5923 31 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5924 31 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5925 31 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5926 31 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5927 31 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5928 //20
5929 31 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5930 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5931 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5932 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5933 31 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5934 31 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5935 31 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5936 31 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5937 31 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5938 31 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5939 //30
5940 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5941 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5942 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5943 31 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5944 };
5945
5946 char zc_builddate[80];
5947 char zc_aboutstr[80];
5948
5949 static DIALOG about_dlg[] =
5950 {
5951 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5952 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5953 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5954 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5955 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5956 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5957 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5958 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5959 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5960 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5961 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5962 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5963 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5964 };
5965
5966
5967 static DIALOG quest_dlg[] =
5968 {
5969 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5970 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5971 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5972 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5973 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5974 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5975 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5976 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5977 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5978 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5979 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5980 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5981 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5982 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5983 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5984 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5985 };
5986
5987 static DIALOG triforce_dlg[] =
5988 {
5989 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5990 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5991 // 1
5992 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5993 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5994 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5995 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5996 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5997 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5998 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5999 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6000 // 9
6001 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6002 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6003 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6004 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6005 };
6006
6007 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6008 {
6009 go();
6010 int32_t ret=0;
6011 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6012 comeback();
6013 return ret != 0;
6014 }
6015
6016
6017 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6018 {
6019 if(def!=modulepath)
6020 strcpy(modulepath,def);
6021
6022 if(!usefilename)
6023 {
6024 int32_t i=(int32_t)strlen(modulepath);
6025
6026 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6027 modulepath[i--]=0;
6028 }
6029
6030 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6031 int32_t ret=0;
6032 int32_t sel=0;
6033
6034 if(list==NULL)
6035 {
6036 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6037 }
6038 else
6039 {
6040 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6041 }
6042
6043 return ret!=0;
6044 }
6045
6046 //The Dialogue that loads a ZMOD Module File
6047 int32_t zc_load_zmod_module_file()
6048 {
6049 if ( Playing )
6050 {
6051 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6052 return -1;
6053 }
6054 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6055 return D_CLOSE;
6056
6057 FILE *tempmodule = fopen(modulepath,"r");
6058
6059 if(tempmodule == NULL)
6060 {
6061 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6062 return -1;
6063 }
6064
6065
6066 //Set the module path:
6067 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6068 strcpy(moduledata.module_name, modulepath);
6069 al_trace("New Module Path is: %s \n", moduledata.module_name);
6070 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6071 zcm.init(true); //Load the module values.
6072 moduledata.refresh_title_screen = 1;
6073 // refresh_select_screen = 1;
6074 build_biic_list();
6075 return D_O_K;
6076 }
6077
6078 static DIALOG module_info_dlg[] =
6079 {
6080 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6081
6082
6083 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6084 //1
6085 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6086 //2
6087 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6088 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6089 //4
6090 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6091 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6092 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6093 //7
6094
6095 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6096 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6097 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6098 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6099 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6100 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6101 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6102 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6103 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6104
6105 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6106 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6107 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6108 };
6109
6110 void about_zcplayer_module(const char *prompt,int32_t initialval)
6111 {
6112
6113 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6114 if ( moduledata.moduletitle[0] != 0 )
6115 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6116
6117 if ( moduledata.moduleauthor[0] != 0 )
6118 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6119
6120 if ( moduledata.moduleinfo0[0] != 0 )
6121 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6122 if ( moduledata.moduleinfo1[0] != 0 )
6123 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6124 if ( moduledata.moduleinfo2[0] != 0 )
6125 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6126 if ( moduledata.moduleinfo3[0] != 0 )
6127 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6128 if ( moduledata.moduleinfo4[0] != 0 )
6129 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6130
6131 char module_date[255];
6132 memset(module_date, 0, sizeof(module_date));
6133 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6134 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6135
6136
6137
6138 char module_vers[255];
6139 memset(module_vers, 0, sizeof(module_vers));
6140 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6141
6142
6143 //sprintf(tilecount,"%d",1);
6144
6145 char module_build[255];
6146 memset(module_build, 0, sizeof(module_build));
6147 if ( moduledata.modbeta )
6148 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6149 else
6150 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6151
6152 module_info_dlg[12].dp = (char*)module_date;
6153 module_info_dlg[13].dp = (char*)module_vers;
6154 module_info_dlg[14].dp = (char*)module_build;
6155
6156 large_dialog(module_info_dlg);
6157
6158 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6159 jwin_center_dialog(module_info_dlg);
6160
6161
6162 }
6163
6164 int32_t onAbout_ZCP_Module()
6165 {
6166 about_zcplayer_module("About Module (.zmod)", 0);
6167 return D_O_K;
6168 }
6169
6170 //New Modules Menu for 2.55+
6171 static MENU zcmodule_menu[] =
6172 {
6173 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6174 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6175
6176 { NULL, NULL, NULL, 0, NULL }
6177 };
6178
6179 int32_t onToggleRecordingNewSaves()
6180 {
6181 if (zc_get_config("zeldadx", "replay_new_saves", false))
6182 {
6183 zc_set_config("zeldadx", "replay_new_saves", false);
6184 }
6185 else
6186 {
6187 zc_set_config("zeldadx", "replay_new_saves", true);
6188 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6189 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6190 }
6191 return D_O_K;
6192 }
6193
6194 int32_t onToggleSnapshotAllFrames()
6195 {
6196 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6197 return D_O_K;
6198 }
6199
6200 int32_t onStopReplayOrRecord()
6201 {
6202 if (replay_is_replaying())
6203 {
6204 replay_quit();
6205 }
6206 else if (replay_get_mode() == ReplayMode::Record)
6207 {
6208 if (!replay_get_meta_bool("test_mode"))
6209 {
6210 jwin_alert("Recording", "You cannot stop recording a save file.",
6211 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6212 return D_CLOSE;
6213 }
6214
6215 if (jwin_alert("Stop Recording",
6216 "Save replay to disk and stop recording?",
6217 "This will stop the recording.",
6218 NULL,
6219 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6220 return D_CLOSE;
6221
6222 replay_save();
6223 replay_stop();
6224 }
6225 return D_O_K;
6226 }
6227
6228 static int32_t handle_on_load_replay(ReplayMode mode)
6229 {
6230 if (Playing)
6231 {
6232 if (jwin_alert("Replay - Warning!",
6233 "Loading a replay will exit the current game.",
6234 "All unsaved progress will be lost.",
6235 "Do you wish to continue?",
6236 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6237 return D_CLOSE;
6238 }
6239
6240 std::string mode_string = replay_mode_to_string(mode);
6241 mode_string[0] = std::toupper(mode_string[0]);
6242
6243 std::string line_1 = "Select a replay file to play back.";
6244 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6245 std::string line_3 = "You can stop the replay and take over manually any time.";
6246 if (mode == ReplayMode::Update)
6247 {
6248 line_1 = "Select a replay file to update.";
6249 line_2 = "WARNING: be sure to back up the zplay file";
6250 line_3 = "and verify that the updated replay works as expected!";
6251 }
6252
6253 if (jwin_alert(mode_string.c_str(),
6254 line_1.c_str(),
6255 line_2.c_str(),
6256 line_3.c_str(),
6257 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6258 {
6259 char replay_path[2048];
6260 strcpy(replay_path, "replays/");
6261 if (jwin_file_select_ex(
6262 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6263 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6264 return D_CLOSE;
6265
6266 replay_quit();
6267 load_replay_file_deferred(mode, replay_path);
6268 Quit = qRESET;
6269 return D_CLOSE;
6270 }
6271 return D_O_K;
6272 }
6273
6274 int32_t onLoadReplay()
6275 {
6276 return handle_on_load_replay(ReplayMode::Replay);
6277 }
6278
6279 int32_t onLoadReplayAssert()
6280 {
6281 return handle_on_load_replay(ReplayMode::Assert);
6282 }
6283
6284 int32_t onLoadReplayUpdate()
6285 {
6286 return handle_on_load_replay(ReplayMode::Update);
6287 }
6288
6289 int32_t onSaveReplay()
6290 {
6291 if (replay_get_mode() == ReplayMode::Record)
6292 {
6293 if (!replay_get_meta_bool("test_mode"))
6294 {
6295 if (jwin_alert("Save Replay",
6296 "This will save a copy of the replay up to this point.",
6297 "The official replay file will be untouched.",
6298 "Do you wish to continue?",
6299 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6300 return D_CLOSE;
6301
6302 char replay_path[2048];
6303 strcpy(replay_path, replay_get_replay_path().string().c_str());
6304 if (jwin_file_select_ex(
6305 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6306 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6307 return D_CLOSE;
6308
6309 if (fileexists(replay_path))
6310 {
6311 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6312 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6313 return D_CLOSE;
6314 }
6315
6316 replay_save(replay_path);
6317 }
6318 else
6319 {
6320 replay_save();
6321 }
6322 }
6323 return D_O_K;
6324 }
6325
6326 static MENU replay_menu[] =
6327 {
6328 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6329 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6330 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6331 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6332 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6333 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6334 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6335
6336 { NULL, NULL, NULL, 0, NULL }
6337 };
6338
6339 static DIALOG credits_dlg[] =
6340 {
6341 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6342 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6343 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6344 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6345 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6346 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6347 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6348 };
6349
6350 31 static ListData dmap_list(dmaplist, &font);
6351
6352 static DIALOG goto_dlg[] =
6353 {
6354 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6355 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6356 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6357 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6358 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6359 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6360 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6361 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6362 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6363 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6364 };
6365
6366 int32_t onGoTo()
6367 {
6368 bool music = false;
6369 music = music;
6370 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6371
6372 goto_dlg[0].dp2=get_zc_font(font_lfont);
6373 goto_dlg[4].d2=cheat_goto_dmap;
6374 goto_dlg[6].dp=cheat_goto_screen_str;
6375
6376 clear_keybuf();
6377
6378 large_dialog(goto_dlg);
6379
6380 if(zc_popup_dialog(goto_dlg,4)==1)
6381 {
6382 // dmap, screen
6383 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6384 };
6385
6386 return D_O_K;
6387 }
6388
6389 int32_t onGoToComplete()
6390 {
6391 if(!Playing)
6392 {
6393 return D_O_K;
6394 }
6395
6396 system_pal();
6397 music_pause();
6398 pause_all_sfx();
6399 sys_mouse();
6400 onGoTo();
6401 eat_buttons();
6402
6403 zc_readrawkey(KEY_ESC);
6404
6405 game_mouse();
6406 game_pal();
6407 music_resume();
6408 resume_all_sfx();
6409 return D_O_K;
6410 }
6411
6412 int32_t onCredits()
6413 {
6414 go();
6415
6416 BITMAP *win = create_bitmap_ex(8,222,110);
6417
6418 if(!win)
6419 return D_O_K;
6420
6421 int32_t c=0;
6422 int32_t l=0;
6423 int32_t ol=-1;
6424 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6425 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6426 PALETTE tmppal;
6427
6428 rti_gui.transparency_index = 1;
6429
6430 clear_to_color(win, rti_gui.transparency_index);
6431 draw_rle_sprite(win,rle,0,0);
6432 credits_dlg[0].dp2=get_zc_font(font_lfont);
6433 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6434 credits_dlg[2].dp = win;
6435
6436 zc_set_palette_range(black_palette,0,127,false);
6437
6438 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6439
6440 BITMAP* old_screen = screen;
6441 BITMAP* gui_bmp = zc_get_gui_bmp();
6442 ASSERT(gui_bmp);
6443 clear_to_color(gui_bmp, rti_gui.transparency_index);
6444 screen = gui_bmp;
6445
6446 while(update_dialog(p))
6447 {
6448 throttleFPS();
6449 ++c;
6450 l = zc_max((c>>1)-30,0);
6451
6452 if(l > rle->h)
6453 l = c = 0;
6454
6455 if(l > rle->h - 112)
6456 l = rle->h - 112;
6457
6458 clear_bitmap(win);
6459 draw_rle_sprite(win,rle,0,0-l);
6460
6461 if(c<=64)
6462 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6463
6464 zc_set_palette_range(tmppal,0,127,false);
6465
6466 if(l!=ol)
6467 {
6468 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6469 SCRFIX();
6470 ol=l;
6471 }
6472
6473 update_hw_screen();
6474 }
6475
6476 screen = old_screen;
6477 system_pal();
6478
6479 shutdown_dialog(p);
6480 destroy_bitmap(win);
6481 //comeback();
6482
6483 rti_gui.transparency_index = 0;
6484 clear_to_color(gui_bmp, rti_gui.transparency_index);
6485
6486 return D_O_K;
6487 }
6488
6489 const char *midilist(int32_t index, int32_t *list_size)
6490 {
6491 if(index<0)
6492 {
6493 *list_size=0;
6494
6495 for(int32_t i=0; i<MAXMIDIS; i++)
6496 if(tunes[i].data)
6497 ++(*list_size);
6498
6499 return NULL;
6500 }
6501
6502 int32_t i=0,m=0;
6503
6504 while(m<=index && i<=MAXMIDIS)
6505 {
6506 if(tunes[i].data)
6507 ++m;
6508
6509 ++i;
6510 }
6511
6512 --i;
6513
6514 if(i==MAXMIDIS && m<index)
6515 return "(null)";
6516
6517 return tunes[i].title;
6518 }
6519
6520 /* ------- MIDI info stuff -------- */
6521
6522 char *text;
6523 midi_info *zmi;
6524 bool dialog_running;
6525 bool listening;
6526
6527 void get_info(int32_t index);
6528
6529 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6530 {
6531 int32_t d2 = d->d2;
6532 int32_t ret = jwin_droplist_proc(msg,d,c);
6533
6534 if(d2!=d->d2)
6535 {
6536 get_info(d->d2);
6537 }
6538
6539 return ret;
6540 }
6541
6542 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6543 {
6544 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6545
6546 int32_t ret = jwin_button_proc(msg,d,c);
6547
6548 if(ret == D_CLOSE)
6549 {
6550 // get current midi index
6551 int32_t index = (d+(d->d1))->d2;
6552 int32_t i=0, m=0;
6553
6554 while(m<=index && i<=MAXMIDIS)
6555 {
6556 if(tunes[i].data)
6557 ++m;
6558
6559 ++i;
6560 }
6561
6562 --i;
6563 jukebox(i);
6564 listening = true;
6565 ret = D_O_K;
6566 }
6567
6568 return ret;
6569 }
6570
6571 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6572 {
6573 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6574
6575 int32_t ret = jwin_button_proc(msg,d,c);
6576
6577 if(ret == D_CLOSE)
6578 {
6579 // get current midi index
6580 int32_t index = (d+(d->d1))->d2;
6581 int32_t i=0, m=0;
6582
6583 while(m<=index && i<=MAXMIDIS)
6584 {
6585 if(tunes[i].data)
6586 ++m;
6587
6588 ++i;
6589 }
6590
6591 --i;
6592
6593 // get file name
6594
6595 int32_t sel=0;
6596 //struct ffblk f;
6597 char title[40] = "Save MIDI: ";
6598 char fname[2048];
6599 memset(fname,0,2048);
6600 static EXT_LIST list[] =
6601 {
6602 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6603 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6604 { NULL, NULL }
6605 };
6606
6607 strcpy(title+11, tunes[i].title);
6608 title[39] = '\0';
6609
6610 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6611 goto done;
6612
6613 if(exists(fname))
6614 {
6615 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6616 goto done;
6617 }
6618
6619 // save midi i
6620
6621 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6622 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6623
6624 done:
6625 chop_path(fname);
6626 ret = D_REDRAW;
6627 }
6628
6629 return ret;
6630 }
6631
6632 31 static ListData midi_list(midilist, &font);
6633
6634 static DIALOG midi_dlg[] =
6635 {
6636 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6637 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6638 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6639 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6640 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6641 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6642 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6643 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6644 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6645 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6646 };
6647
6648 void get_info(int32_t index)
6649 {
6650 int32_t i=0, m=0;
6651
6652 while(m<=index && i<=MAXMIDIS)
6653 {
6654 if(tunes[i].data)
6655 ++m;
6656
6657 ++i;
6658 }
6659
6660 --i;
6661
6662 if(i==MAXMIDIS && m<index)
6663 strcpy(text,"(null)");
6664 else
6665 {
6666 get_midi_info((MIDI*)tunes[i].data,zmi);
6667 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6668 }
6669
6670 midi_dlg[0].dp2=get_zc_font(font_lfont);
6671 midi_dlg[3].dp = text;
6672 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6673 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6674
6675 if(dialog_running)
6676 {
6677 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6678 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6679 }
6680 }
6681
6682 int32_t onMIDICredits()
6683 {
6684 text = (char*)malloc(4096);
6685 zmi = (midi_info*)malloc(sizeof(midi_info));
6686
6687 if(!text || !zmi)
6688 {
6689 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6690 return D_O_K;
6691 }
6692
6693 bool do_pause_midi = midi_pos >= 0 && currmidi;
6694 auto restore_midi = currmidi;
6695 if(do_pause_midi)
6696 {
6697 paused_midi_pos = midi_pos;
6698 stop_midi();
6699 midi_paused=true;
6700 midi_suspended = midissuspHALTED;
6701 }
6702
6703 midi_dlg[0].dp2=get_zc_font(font_lfont);
6704 midi_dlg[2].d1 = 0;
6705 midi_dlg[2].d2 = 0;
6706 midi_dlg[4].flags = D_EXIT;
6707 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6708
6709 listening = false;
6710 dialog_running=false;
6711 get_info(0);
6712
6713 dialog_running=true;
6714
6715 large_dialog(midi_dlg);
6716
6717 zc_popup_dialog(midi_dlg,0);
6718 dialog_running=false;
6719
6720 if(listening)
6721 music_stop();
6722
6723 if(do_pause_midi)
6724 {
6725 midi_suspended = midissuspRESUME;
6726 currmidi = restore_midi;
6727 midi_pos = paused_midi_pos;
6728 }
6729
6730 if(text) free(text);
6731 if(zmi) free(zmi);
6732 return D_O_K;
6733 }
6734
6735 int32_t onAbout()
6736 {
6737 char buf1[80]={0};
6738 std::ostringstream oss;
6739 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6740 oss << buf1 << '\n';
6741 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6742 oss << buf1 << '\n';
6743 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6744 oss << buf1 << '\n';
6745 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6746 oss << buf1 << '\n';
6747 sprintf(buf1, "Tag: %s", getReleaseTag());
6748 oss << buf1 << '\n';
6749
6750 InfoDialog("About ZC", oss.str()).show();
6751 return D_O_K;
6752 }
6753
6754 int32_t onQuest()
6755 {
6756 char fname[100];
6757 strcpy(fname, get_filename(qstpath));
6758 quest_dlg[0].dp2=get_zc_font(font_lfont);
6759 quest_dlg[1].dp = fname;
6760
6761 if(QHeader.quest_number==0)
6762 sprintf(str_a,"Custom");
6763 else
6764 sprintf(str_a,"%d",QHeader.quest_number);
6765
6766 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6767
6768 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6769 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6770
6771 large_dialog(quest_dlg);
6772
6773 zc_popup_dialog(quest_dlg, 0);
6774 return D_O_K;
6775 }
6776
6777 void call_vidmode_dlg();
6778 int32_t onVidMode()
6779 {
6780 call_vidmode_dlg();
6781 return D_O_K;
6782 }
6783
6784 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6785 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6786 //Added an extra statement, so that if the key is cleared to 0, the cleared
6787 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6788
6789 void load_ukeys(int32_t* arr)
6790 {
6791 arr[ukey_a] = Akey;
6792 arr[ukey_b] = Bkey;
6793 arr[ukey_s] = Skey;
6794 arr[ukey_l] = Lkey;
6795 arr[ukey_r] = Rkey;
6796 arr[ukey_p] = Pkey;
6797 arr[ukey_ex1] = Exkey1;
6798 arr[ukey_ex2] = Exkey2;
6799 arr[ukey_ex3] = Exkey3;
6800 arr[ukey_ex4] = Exkey4;
6801 arr[ukey_du] = DUkey;
6802 arr[ukey_dd] = DDkey;
6803 arr[ukey_dl] = DLkey;
6804 arr[ukey_dr] = DRkey;
6805 arr[ukey_mod1a] = cheat_modifier_keys[0];
6806 arr[ukey_mod1b] = cheat_modifier_keys[1];
6807 arr[ukey_mod2a] = cheat_modifier_keys[2];
6808 arr[ukey_mod2b] = cheat_modifier_keys[3];
6809 };
6810
6811 static const char* ukey_names[] = {
6812 "A", "B", "Start", "L", "R", "Map",
6813 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6814 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6815 "Cheat Mod R1", "Cheat Mod R2",
6816 };
6817 std::string get_ukey_name(int32_t k)
6818 {
6819 if (k < num_ukey) return ukey_names[k];
6820 return "";
6821 }
6822
6823 int32_t onKeyboard()
6824 {
6825 int32_t a = Akey;
6826 int32_t b = Bkey;
6827 int32_t s = Skey;
6828 int32_t l = Lkey;
6829 int32_t r = Rkey;
6830 int32_t p = Pkey;
6831 int32_t ex1 = Exkey1;
6832 int32_t ex2 = Exkey2;
6833 int32_t ex3 = Exkey3;
6834 int32_t ex4 = Exkey4;
6835 int32_t du = DUkey;
6836 int32_t dd = DDkey;
6837 int32_t dl = DLkey;
6838 int32_t dr = DRkey;
6839 int32_t mod1a = cheat_modifier_keys[0];
6840 int32_t mod1b = cheat_modifier_keys[1];
6841 int32_t mod2a = cheat_modifier_keys[2];
6842 int32_t mod2b = cheat_modifier_keys[3];
6843 bool done=false;
6844 int32_t ret;
6845
6846 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6847
6848 large_dialog(keyboard_control_dlg);
6849
6850 while(!done)
6851 {
6852 ret = zc_popup_dialog(keyboard_control_dlg,3);
6853
6854 if(ret==3) // OK
6855 {
6856 int32_t ukeys[num_ukey];
6857 load_ukeys(ukeys);
6858 std::vector<std::string> uniqueError;
6859 for(int32_t q = 0; q < num_ukey; ++q)
6860 {
6861 for(int32_t p = q+1; p < num_ukey; ++p)
6862 {
6863 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6864 {
6865 char buf[64];
6866 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6867 std::string str(buf);
6868 uniqueError.push_back(str);
6869 }
6870 }
6871 }
6872 if(uniqueError.size() == 0)
6873 {
6874 done = true;
6875 save_control_configs(true);
6876 }
6877 else
6878 {
6879 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6880 box_out("Cannot have duplicate keybinds!"); box_eol();
6881 for(std::vector<std::string>::iterator it = uniqueError.begin();
6882 it != uniqueError.end(); ++it)
6883 {
6884 box_out((*it).c_str()); box_eol();
6885 }
6886 box_end(true);
6887 }
6888 }
6889 else // Cancel
6890 {
6891 Akey = a;
6892 Bkey = b;
6893 Skey = s;
6894 Lkey = l;
6895 Rkey = r;
6896 Pkey = p;
6897 Exkey1 = ex1;
6898 Exkey2 = ex2;
6899 Exkey3 = ex3;
6900 Exkey4 = ex4;
6901 DUkey = du;
6902 DDkey = dd;
6903 DLkey = dl;
6904 DRkey = dr;
6905 cheat_modifier_keys[0] = mod1a;
6906 cheat_modifier_keys[1] = mod1b;
6907 cheat_modifier_keys[2] = mod2a;
6908 cheat_modifier_keys[3] = mod2b;
6909
6910 done=true;
6911 }
6912
6913 rest(1);
6914 }
6915
6916 return D_O_K;
6917 }
6918
6919 int32_t onGamepad()
6920 {
6921 int32_t a = Abtn;
6922 int32_t b = Bbtn;
6923 int32_t s = Sbtn;
6924 int32_t l = Lbtn;
6925 int32_t r = Rbtn;
6926 int32_t m = Mbtn;
6927 int32_t p = Pbtn;
6928 int32_t ex1 = Exbtn1;
6929 int32_t ex2 = Exbtn2;
6930 int32_t ex3 = Exbtn3;
6931 int32_t ex4 = Exbtn4;
6932 int32_t up = DUbtn;
6933 int32_t down = DDbtn;
6934 int32_t left = DLbtn;
6935 int32_t right = DRbtn;
6936
6937 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6938 if(analog_movement)
6939 gamepad_dlg[56].flags|=D_SELECTED;
6940 else
6941 gamepad_dlg[56].flags&=~D_SELECTED;
6942
6943 large_dialog(gamepad_dlg);
6944
6945 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6946
6947 if(ret == 4) //OK
6948 {
6949 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6950 save_control_configs(false);
6951 }
6952 else //Cancel
6953 {
6954 Abtn = a;
6955 Bbtn = b;
6956 Sbtn = s;
6957 Lbtn = l;
6958 Rbtn = r;
6959 Mbtn = m;
6960 Pbtn = p;
6961 Exbtn1 = ex1;
6962 Exbtn2 = ex2;
6963 Exbtn3 = ex3;
6964 Exbtn4 = ex4;
6965 DUbtn = up;
6966 DDbtn = down;
6967 DLbtn = left;
6968 DRbtn = right;
6969 }
6970
6971 return D_O_K;
6972 }
6973
6974 int32_t onCheatKeys()
6975 {
6976 int32_t oldcheats[Cheat::Last][2];
6977 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6978
6979 bool done=false;
6980
6981 while(!done)
6982 {
6983 bool confirm = false;
6984 CheatKeysDialog(&confirm).show();
6985 if(confirm) // OK
6986 {
6987 std::vector<std::string> uniqueError;
6988 char buf[512];
6989 for(size_t q = 1; q < Cheat::Last; ++q)
6990 {
6991 if(cheatkeys[q][1] && !cheatkeys[q][0])
6992 {
6993 cheatkeys[q][0] = cheatkeys[q][1];
6994 cheatkeys[q][1] = 0;
6995 }
6996 }
6997 for(size_t q = 1; q < Cheat::Last; ++q)
6998 {
6999 if(!bindable_cheat((Cheat)q)) continue;
7000 for(size_t p = q+1; p < Cheat::Last; ++p)
7001 {
7002 if(!bindable_cheat((Cheat)p)) continue;
7003 for(size_t q2 = 0; q2 <= 1; ++q2)
7004 for(size_t p2 = 0; p2 <= 1; ++p2)
7005 {
7006 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
7007 {
7008 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
7009 cheat_to_string((Cheat)q), q2?"Alt":"Main",
7010 cheat_to_string((Cheat)p), p2?"Alt":"Main",
7011 get_keystr(cheatkeys[q][q2])));
7012 }
7013 }
7014 }
7015 }
7016 if(uniqueError.size() == 0)
7017 {
7018 done = true;
7019 save_cheatkeys();
7020 }
7021 else
7022 {
7023 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
7024 box_out("Cannot have duplicate keybinds!"); box_eol();
7025 for(std::vector<std::string>::iterator it = uniqueError.begin();
7026 it != uniqueError.end(); ++it)
7027 {
7028 box_out((*it).c_str()); box_eol();
7029 }
7030 box_end(true);
7031 }
7032 }
7033 else // Cancel
7034 {
7035 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
7036 done=true;
7037 }
7038 rest(1);
7039 }
7040
7041 return D_O_K;
7042 }
7043
7044 int32_t onSound()
7045 {
7046 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7047 {
7048 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7049 }
7050 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7051 {
7052 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7053 }
7054 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7055 {
7056 emusic_volume = (int32_t)FFCore.usr_music_volume;
7057 }
7058 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7059 {
7060 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7061 }
7062 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7063 {
7064 pan_style = (int32_t)FFCore.usr_panstyle;
7065 }
7066
7067 int32_t m = midi_volume;
7068 int32_t d = digi_volume;
7069 int32_t e = emusic_volume;
7070 int32_t b = zcmusic_bufsz;
7071 int32_t s = sfx_volume;
7072 int32_t p = pan_style;
7073 pan_style = vbound(pan_style,0,3);
7074
7075 sound_dlg[0].dp2=get_zc_font(font_lfont);
7076
7077 large_dialog(sound_dlg);
7078
7079 midi_dp[1] = sound_dlg[6].x;
7080 midi_dp[2] = sound_dlg[6].y;
7081 digi_dp[1] = sound_dlg[7].x;
7082 digi_dp[2] = sound_dlg[7].y;
7083 emus_dp[1] = sound_dlg[8].x;
7084 emus_dp[2] = sound_dlg[8].y;
7085 buf_dp[1] = sound_dlg[9].x;
7086 buf_dp[2] = sound_dlg[9].y;
7087 sfx_dp[1] = sound_dlg[10].x;
7088 sfx_dp[2] = sound_dlg[10].y;
7089 pan_dp[1] = sound_dlg[11].x;
7090 pan_dp[2] = sound_dlg[11].y;
7091 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7092 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7093 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7094 sound_dlg[18].d2 = zcmusic_bufsz;
7095 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7096 sound_dlg[20].d2 = pan_style;
7097
7098 int32_t ret = zc_popup_dialog(sound_dlg,1);
7099
7100 if(ret==2)
7101 {
7102 master_volume(digi_volume,midi_volume);
7103
7104 for(int32_t i=0; i<WAV_COUNT; ++i)
7105 {
7106 //allegro assertion fails when passing in -1 as voice -DD
7107 if(sfx_voice[i] > 0)
7108 voice_set_volume(sfx_voice[i], sfx_volume);
7109 }
7110 zc_set_config(sfx_sect,"digi",digi_volume);
7111 zc_set_config(sfx_sect,"midi",midi_volume);
7112 zc_set_config(sfx_sect,"sfx",sfx_volume);
7113 zc_set_config(sfx_sect,"emusic",emusic_volume);
7114 zc_set_config(sfx_sect,"pan",pan_style);
7115 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7116 }
7117 else
7118 {
7119 midi_volume = m;
7120 digi_volume = d;
7121 emusic_volume = e;
7122 zcmusic_bufsz = b;
7123 sfx_volume = s;
7124 pan_style = p;
7125 }
7126
7127 return D_O_K;
7128 }
7129
7130 int32_t queding(char const* s1, char const* s2, char const* s3)
7131 {
7132 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7133 }
7134
7135 int32_t onQuit()
7136 {
7137 if(Playing)
7138 {
7139 int32_t ret=0;
7140
7141 if(get_bit(quest_rules, qr_NOCONTINUE))
7142 {
7143 if(standalone_mode)
7144 {
7145 ret=queding("End current game?",
7146 "The continue screen is disabled; the game",
7147 "will be reloaded from the last save.");
7148 }
7149 else
7150 {
7151 ret=queding("End current game?",
7152 "The continue screen is disabled. You will",
7153 "be returned to the file select screen.");
7154 }
7155 }
7156 else
7157 ret=queding("End current game?",NULL,NULL);
7158
7159 if(ret==1)
7160 {
7161 disableClickToFreeze=false;
7162 Quit=qQUIT;
7163
7164 // Trying to evade a door repair charge?
7165 if(repaircharge)
7166 {
7167 game->change_drupy(-repaircharge);
7168 repaircharge=0;
7169 }
7170
7171 return D_CLOSE;
7172 }
7173 }
7174
7175 return D_O_K;
7176 }
7177
7178 int32_t onTryQuitMenu()
7179 {
7180 return onTryQuit(true);
7181 }
7182
7183 int32_t onTryQuit(bool inMenu)
7184 {
7185 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7186 {
7187 if(active_cutscene.can_f6())
7188 {
7189 if(get_bit(quest_rules,qr_OLD_F6))
7190 {
7191 if(inMenu) onQuit();
7192 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7193 }
7194 else
7195 {
7196 disableClickToFreeze=false;
7197 GameFlags |= GAMEFLAG_TRYQUIT;
7198 }
7199 return D_CLOSE;
7200 }
7201 else active_cutscene.error();
7202 }
7203
7204 return D_O_K;
7205 }
7206
7207 int32_t onReset()
7208 {
7209 if(queding(" Reset system? ",NULL,NULL)==1)
7210 {
7211 disableClickToFreeze=false;
7212 Quit=qRESET;
7213 replay_quit();
7214 return D_CLOSE;
7215 }
7216
7217 return D_O_K;
7218 }
7219
7220 int32_t onExit()
7221 {
7222 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7223 {
7224 Quit=qEXIT;
7225 return D_CLOSE;
7226 }
7227
7228 return D_O_K;
7229 }
7230
7231 int32_t onTitle_NES()
7232 {
7233 title_version=0;
7234 zc_set_config(cfg_sect,"title",title_version);
7235 return D_O_K;
7236 }
7237 int32_t onTitle_DX()
7238 {
7239 title_version=1;
7240 zc_set_config(cfg_sect,"title",title_version);
7241 return D_O_K;
7242 }
7243 int32_t onTitle_25()
7244 {
7245 title_version=2;
7246 zc_set_config(cfg_sect,"title",title_version);
7247 return D_O_K;
7248 }
7249
7250 int32_t onDebug()
7251 {
7252 if(debug_enabled)
7253 set_debug(!get_debug());
7254 return D_O_K;
7255 }
7256
7257 int32_t onHeartBeep()
7258 {
7259 heart_beep=!heart_beep;
7260 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7261 return D_O_K;
7262 }
7263
7264 int32_t onSaveIndicator()
7265 {
7266 use_save_indicator=!use_save_indicator;
7267 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7268 return D_O_K;
7269 }
7270
7271 int32_t onEpilepsy()
7272 {
7273 if(jwin_alert3(
7274 "Epilepsy Flash Reduction",
7275 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7276 "Disabling this will restore standard flash and wavy behaviour.",
7277 "Proceed?",
7278 "&Yes",
7279 "&No",
7280 NULL,
7281 'y',
7282 'n',
7283 0,
7284 get_zc_font(font_lfont)) == 1)
7285 {
7286 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7287 zc_set_config("zeldadx","checked_epilepsy",1);
7288 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7289 }
7290 return D_O_K;
7291 }
7292
7293 int32_t onTriforce()
7294 {
7295 for(int32_t i=0; i<MAXINITTABS; ++i)
7296 {
7297 init_tabs[i].flags&=~D_SELECTED;
7298 }
7299
7300 init_tabs[3].flags=D_SELECTED;
7301 return onCheatConsole();
7302 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7303 for(int32_t i=1; i<=8; i++)
7304 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7305
7306 if(zc_popup_dialog (triforce_dlg,-1)==9)
7307 {
7308 for(int32_t i=1; i<=8; i++)
7309 {
7310 game->lvlitems[i] &= ~liTRIFORCE;
7311 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7312 }
7313 }
7314 return D_O_K;*/
7315 }
7316
7317 bool rc = false;
7318 /*
7319 int32_t onEquipment()
7320 {
7321 for (int32_t i=0; i<MAXINITTABS; ++i)
7322 {
7323 init_tabs[i].flags&=~D_SELECTED;
7324 }
7325 init_tabs[0].flags=D_SELECTED;
7326 return onCheatConsole();
7327 }
7328 */
7329
7330 int32_t onItems()
7331 {
7332 for(int32_t i=0; i<MAXINITTABS; ++i)
7333 {
7334 init_tabs[i].flags&=~D_SELECTED;
7335 }
7336
7337 init_tabs[1].flags=D_SELECTED;
7338 return onCheatConsole();
7339 }
7340
7341 static DIALOG getnum_dlg[] =
7342 {
7343 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7344 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7345 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7346 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7347 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7348 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7349 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7350 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7351 };
7352
7353 int32_t getnumber(const char *prompt,int32_t initialval)
7354 {
7355 char buf[20];
7356 sprintf(buf,"%d",initialval);
7357 getnum_dlg[0].dp=(void *)prompt;
7358 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7359 getnum_dlg[2].dp=buf;
7360
7361 large_dialog(getnum_dlg);
7362
7363 if(zc_popup_dialog(getnum_dlg,2)==3)
7364 return atoi(buf);
7365
7366 return initialval;
7367 }
7368
7369 int32_t onLife()
7370 {
7371 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7372 cheats_enqueue(Cheat::Life, value);
7373 return D_O_K;
7374 }
7375
7376 int32_t onHeartC()
7377 {
7378 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7379 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7380 cheats_enqueue(Cheat::MaxLife, max_life);
7381 cheats_enqueue(Cheat::Life, life);
7382 return D_O_K;
7383 }
7384
7385 int32_t onMagicC()
7386 {
7387 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7388 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7389 cheats_enqueue(Cheat::MaxMagic, max_magic);
7390 cheats_enqueue(Cheat::Magic, magic);
7391 return D_O_K;
7392 }
7393
7394 int32_t onRupies()
7395 {
7396 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7397 cheats_enqueue(Cheat::Rupies, value);
7398 return D_O_K;
7399 }
7400
7401 int32_t onMaxBombs()
7402 {
7403 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7404 cheats_enqueue(Cheat::MaxBombs, value);
7405 cheats_enqueue(Cheat::Bombs, value);
7406 return D_O_K;
7407 }
7408
7409 int32_t onRefillLife()
7410 {
7411 cheats_enqueue(Cheat::Life, game->get_maxlife());
7412 return D_O_K;
7413 }
7414 int32_t onRefillMagic()
7415 {
7416 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7417 return D_O_K;
7418 }
7419 int32_t onClock()
7420 {
7421 cheats_enqueue(Cheat::Clock);
7422 return D_O_K;
7423 }
7424
7425 int32_t onQstPath()
7426 {
7427 char path[2048];
7428
7429 chop_path(qstdir);
7430 strcpy(path,qstdir);
7431
7432 go();
7433
7434 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7435 {
7436 chop_path(path);
7437 fix_filename_case(path);
7438 fix_filename_slashes(path);
7439 strcpy(qstdir,path);
7440 strcpy(qstpath,qstdir);
7441 }
7442
7443 comeback();
7444 return D_O_K;
7445 }
7446
7447 #include "dialog/cheat_dialog.h"
7448 int32_t onCheat()
7449 {
7450 call_setcheat_dialog();
7451 game->set_cheat(maxcheat);
7452 if(cheat) game->did_cheat(true);
7453 return D_O_K;
7454 }
7455
7456 int32_t onCheatRupies()
7457 {
7458 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7459 return D_O_K;
7460 }
7461
7462 int32_t onCheatArrows()
7463 {
7464 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7465 return D_O_K;
7466 }
7467
7468 int32_t onCheatBombs()
7469 {
7470 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7471 return D_O_K;
7472 }
7473
7474 // *** screen saver
7475
7476 7516455 int32_t after_time()
7477 {
7478
1/2
✓ Branch 0 taken 7516455 times.
✗ Branch 1 not taken.
7516455 if(ss_enable == 0)
7479 return INT_MAX;
7480
7481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
7516455 if(ss_after <= 0)
7482 return 5 * 60;
7483
7484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
7516455 if(ss_after <= 3)
7485 return ss_after * 15 * 60;
7486
7487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7516455 times.
7516455 if(ss_after <= 13)
7488 return (ss_after - 3) * 60 * 60;
7489
7490 7516455 return MAX_IDLE + 1;
7491 7516455 }
7492
7493 static const char *after_str[15] =
7494 {
7495 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7496 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7497 "Never"
7498 };
7499
7500 const char *after_list(int32_t index, int32_t *list_size)
7501 {
7502 if(index < 0)
7503 {
7504 *list_size = 15;
7505 return NULL;
7506 }
7507
7508 return after_str[index];
7509 }
7510
7511 31 static ListData after__list(after_list, &font);
7512
7513 static DIALOG scrsaver_dlg[] =
7514 {
7515 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7516 31 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7517 31 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7518 31 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7519 31 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7520 31 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7521 31 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7522 31 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7523 31 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7524 31 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7525 31 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7526 31 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7527 31 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7528 31 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7529 };
7530
7531 int32_t onScreenSaver()
7532 {
7533 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7534 int32_t oldcfgs[3];
7535 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7536 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7537 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7538
7539 large_dialog(scrsaver_dlg);
7540
7541 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7542
7543 if(ret == 8 || ret == 9)
7544 {
7545 ss_after = scrsaver_dlg[5].d1;
7546 ss_speed = scrsaver_dlg[6].d2;
7547 ss_density = scrsaver_dlg[7].d2;
7548 if(oldcfgs[0] != ss_after)
7549 zc_set_config(cfg_sect,"ss_after",ss_after);
7550 if(oldcfgs[1] != ss_speed)
7551 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7552 if(oldcfgs[2] != ss_density)
7553 zc_set_config(cfg_sect,"ss_density",ss_density);
7554 }
7555
7556 if(ret == 9)
7557 // preview Screen Saver
7558 {
7559 clear_keybuf();
7560 Matrix(ss_speed, ss_density, 30);
7561 system_pal();
7562 }
7563
7564 return D_O_K;
7565 }
7566
7567 /***** Menus *****/
7568
7569 static MENU game_menu[] =
7570 {
7571 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7572 { (char *)"", NULL, NULL, 0, NULL },
7573 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7574 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7575 { (char *)"", NULL, NULL, 0, NULL },
7576 #ifdef __EMSCRIPTEN__
7577 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7578 #elif defined(ALLEGRO_MACOSX)
7579 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7580 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7581 #else
7582 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7583 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7584 #endif
7585 { NULL, NULL, NULL, 0, NULL }
7586 };
7587
7588 static MENU title_menu[] =
7589 {
7590 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7591 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7592 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7593 { NULL, NULL, NULL, 0, NULL }
7594 };
7595
7596 static MENU snapshot_format_menu[] =
7597 {
7598 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7599 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7600 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7601 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7602 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7603 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7604 { NULL, NULL, NULL, 0, NULL }
7605 };
7606
7607 static MENU controls_menu[] =
7608 {
7609 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7610 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7611 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7612 { NULL, NULL, NULL, 0, NULL }
7613 };
7614
7615 static MENU name_entry_mode_menu[] =
7616 {
7617 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7618 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7619 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7620 { NULL, NULL, NULL, 0, NULL }
7621 };
7622
7623 static void set_controls_menu_active()
7624 {
7625
7626 }
7627
7628 static MENU window_menu[] =
7629 {
7630 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7631 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7632 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7633 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7634 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7635 { NULL, NULL, NULL, 0, NULL }
7636 };
7637 static MENU options_menu[] =
7638 {
7639 { "&Title Screen", NULL, title_menu, 0, NULL },
7640 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7641 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7642 { "&Window Settings", NULL, window_menu, 0, NULL },
7643 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7644 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7645 { NULL, NULL, NULL, 0, NULL }
7646 };
7647 static MENU settings_menu[] =
7648 {
7649 { "&Sound...", onSound, NULL, 0, NULL },
7650 { "C&ontrols", NULL, controls_menu, 0, NULL },
7651 { "", NULL, NULL, 0, NULL },
7652 { "Options", NULL, options_menu, 0, NULL },
7653 { "", NULL, NULL, 0, NULL },
7654 //
7655 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7656 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7657 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7658 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7659 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7660 //
7661 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7662 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7663 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7664 { "", NULL, NULL, 0, NULL },
7665 { "Debu&g", onDebug, NULL, 0, NULL },
7666 //
7667 { NULL, NULL, NULL, 0, NULL }
7668 };
7669
7670
7671 static MENU misc_menu[] =
7672 {
7673 { (char *)"&About...", onAbout, NULL, 0, NULL },
7674 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7675 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7676 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7677 { (char *)"", NULL, NULL, 0, NULL },
7678 //5
7679 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7680 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7681 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7682 { (char *)"", NULL, NULL, 0, NULL },
7683 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7684 //10
7685 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7686 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7687 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7688 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7689 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7690 //15
7691 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7692 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7693 { NULL, NULL, NULL, 0, NULL }
7694 };
7695
7696 static MENU refill_menu[] =
7697 {
7698 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7699 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7700 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7701 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7702 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7703 { NULL, NULL, NULL, 0, NULL }
7704 };
7705
7706 static MENU show_menu[] =
7707 {
7708 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7709 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7710 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7711 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7712 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7713 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7714 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7715 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7716 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7717 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7718 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7719 { (char *)"", NULL, NULL, 0, NULL },
7720 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7721 { (char *)"", NULL, NULL, 0, NULL },
7722 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7723 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7724 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7725 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7726 { NULL, NULL, NULL, 0, NULL }
7727 };
7728
7729 static MENU cheat_menu[] =
7730 {
7731 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7732 { (char *)"", NULL, NULL, 0, NULL },
7733 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7734 { (char *)"", NULL, NULL, 0, NULL },
7735 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7736 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7737 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7738 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7739 { (char *)"", NULL, NULL, 0, NULL },
7740 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7741 { (char *)"", NULL, NULL, 0, NULL },
7742 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7743 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7744 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7745 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7746 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7747 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7748 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7749 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7750 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7751 { NULL, NULL, NULL, 0, NULL }
7752 };
7753
7754 #if DEVLEVEL > 0
7755 int32_t devLogging();
7756 int32_t devDebug();
7757 int32_t devTimestmp();
7758 #if DEVLEVEL > 1
7759 int32_t setCheat();
7760 #endif //DEVLEVEL > 1
7761 enum
7762 {
7763 dv_log,
7764 // dv_dbg,
7765 dv_tmpstmp,
7766 #if DEVLEVEL > 1
7767 dv_nil,
7768 dv_setcheat,
7769 #endif //DEVLEVEL > 1
7770 dv_max
7771 };
7772 static MENU dev_menu[] =
7773 {
7774 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7775 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7776 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7777 #if DEVLEVEL > 1
7778 { (char *)"", NULL, NULL, 0, NULL },
7779 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7780 #endif //DEVLEVEL > 1
7781 { NULL, NULL, NULL, 0, NULL }
7782 };
7783 int32_t devLogging()
7784 {
7785 dev_logging = !dev_logging;
7786 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7787 return D_O_K;
7788 }
7789 // int32_t devDebug()
7790 // {
7791 // dev_debug = !dev_debug;
7792 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7793 // return D_O_K;
7794 // }
7795 int32_t devTimestmp()
7796 {
7797 dev_timestmp = !dev_timestmp;
7798 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7799 return D_O_K;
7800 }
7801 #if DEVLEVEL > 1
7802 int32_t setCheat()
7803 {
7804 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7805 return D_O_K;
7806 }
7807 #endif //DEVLEVEL > 1
7808 #endif //DEVLEVEL > 0
7809
7810 MENU the_player_menu[] =
7811 {
7812 { (char *)"&Game", NULL, game_menu, 0, NULL },
7813 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7814 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7815 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7816 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7817 #if DEVLEVEL > 0
7818 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7819 #endif
7820 { NULL, NULL, NULL, 0, NULL }
7821 };
7822 int32_t onMIDIPatch()
7823 {
7824 if(jwin_alert3(
7825 "Toggle Windows MIDI Fix",
7826 "This action will change whether ZC Player auto-restarts a MIDI at its",
7827 "last index if you move ZC Player out of focus, then back into focus.",
7828 "Proceed?",
7829 "&Yes",
7830 "&No",
7831 NULL,
7832 'y',
7833 'n',
7834 0,
7835 get_zc_font(font_lfont)) == 1)
7836 {
7837 midi_patch_fix = midi_patch_fix ? 0 : 1;
7838 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7839 }
7840 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7841 return D_O_K;
7842 }
7843
7844 int32_t onKeyboardEntry()
7845 {
7846 NameEntryMode=0;
7847 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7848 return D_O_K;
7849 }
7850
7851 int32_t onLetterGridEntry()
7852 {
7853 NameEntryMode=1;
7854 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7855 return D_O_K;
7856 }
7857
7858 int32_t onExtLetterGridEntry()
7859 {
7860 NameEntryMode=2;
7861 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7862 return D_O_K;
7863 }
7864
7865 static BITMAP* oldscreen;
7866 int32_t onFullscreenMenu()
7867 {
7868 // super hacks
7869 screen = oldscreen;
7870 if (onFullscreen() == D_REDRAW)
7871 {
7872 oldscreen = screen;
7873 }
7874 screen = menu_bmp;
7875 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7876 return D_O_K;
7877 }
7878
7879 31 void fix_menu()
7880 {
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!debug_enabled)
7882 31 settings_menu[13].text = NULL;
7883 31 }
7884
7885 static DIALOG system_dlg[] =
7886 {
7887 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7888 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7889 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7890 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7891 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7892 #ifndef ALLEGRO_MACOSX
7893 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7894 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7895 #else
7896 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7897 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7898 #endif
7899 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7900 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7901 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7902 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7903 };
7904
7905 void reset_snapshot_format_menu()
7906 {
7907 for(int32_t i=0; i<ssfmtMAX; ++i)
7908 {
7909 snapshot_format_menu[i].flags=0;
7910 }
7911 }
7912
7913 int32_t onSetSnapshotFormat()
7914 {
7915 switch(active_menu->text[1])
7916 {
7917 case 'B': //"&BMP"
7918 SnapshotFormat=0;
7919 break;
7920
7921 case 'G': //"&GIF"
7922 SnapshotFormat=1;
7923 break;
7924
7925 case 'J': //"&JPG"
7926 SnapshotFormat=2;
7927 break;
7928
7929 case 'P': //"&PNG"
7930 SnapshotFormat=3;
7931 break;
7932
7933 case 'C': //"PC&X"
7934 SnapshotFormat=4;
7935 break;
7936
7937 case 'T': //"&TGA"
7938 SnapshotFormat=5;
7939 break;
7940
7941 case 'L': //"&LBM"
7942 SnapshotFormat=6;
7943 break;
7944 }
7945 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7946
7947 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7948 return D_O_K;
7949 }
7950
7951
7952 44 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7953 {
7954 PALETTE tmp;
7955
7956
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 44 times.
11308 for(int32_t i=0; i<256; i++)
7957 {
7958 11264 tmp[i].r=r;
7959 11264 tmp[i].g=g;
7960 11264 tmp[i].b=b;
7961 11264 }
7962
7963 44 fade_interpolate(src,tmp,dest,pos,from,to);
7964 44 }
7965
7966 44 void system_pal()
7967 {
7968 44 is_sys_pal = true;
7969 static PALETTE pal;
7970 44 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7971
7972 // set up the grayscale palette
7973
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 44 times.
2860 for(int32_t i=128; i<192; i++)
7974 {
7975 2816 pal[i].r = i-128;
7976 2816 pal[i].g = i-128;
7977 2816 pal[i].b = i-128;
7978 2816 }
7979 44 load_colorset(gui_colorset, pal, jwin_a5_colors);
7980
7981 44 color_layer(pal, pal, 24,16,16, 28, 128,191);
7982
7983
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 44 times.
5676 for(int32_t i=0; i<256; i+=2)
7984 {
7985 5632 int32_t v = (i>>3)+2;
7986 5632 int32_t c = (i>>3)+192;
7987 5632 pal[c] = _RGB(v,v,v+(v>>1));
7988 /*
7989 if(i<240)
7990 {
7991 _allegro_hline(tmp_scr,0,i,319,c);
7992 _allegro_hline(tmp_scr,0,i+1,319,c);
7993 }
7994 */
7995 5632 }
7996
7997 // draw the vertical screen gradient
7998
2/2
✓ Branch 0 taken 10560 times.
✓ Branch 1 taken 44 times.
10604 for(int32_t i=0; i<240; ++i)
7999 {
8000 10560 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8001 10560 }
8002
8003 /*
8004 palrstart= 10*63/255; palrend=166*63/255;
8005 palgstart= 36*63/255; palgend=202*63/255;
8006 palbstart=106*63/255; palbend=240*63/255;
8007 paldivs=32;
8008 for(int32_t i=0; i<paldivs; i++)
8009 {
8010 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8011 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8012 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8013 }
8014 */
8015 44 BITMAP *panorama = create_bitmap_ex(8,256,224);
8016 int32_t ts_height, ts_start;
8017
8018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8019 {
8020 clear_to_color(panorama,0);
8021 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8022 ts_height=224-passive_subscreen_height;
8023 ts_start=28;
8024 }
8025 else
8026 {
8027 44 blit(framebuf,panorama,0,0,0,0,256,224);
8028 44 ts_height=224;
8029 44 ts_start=0;
8030 }
8031
8032 // gray scale the current frame
8033
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 44 times.
9900 for(int32_t y=0; y<ts_height; y++)
8034 {
8035
2/2
✓ Branch 0 taken 2523136 times.
✓ Branch 1 taken 9856 times.
2532992 for(int32_t x=0; x<256; x++)
8036 {
8037 2523136 int32_t c = panorama->line[y+ts_start][x];
8038
2/2
✓ Branch 0 taken 2517544 times.
✓ Branch 1 taken 5592 times.
2523136 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8039 2523136 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8040 2523136 }
8041 9856 }
8042
8043 44 destroy_bitmap(panorama);
8044
8045 // display everything
8046 44 vsync();
8047 44 hw_palette = &pal;
8048 44 update_hw_pal = true;
8049
8050 // sys_pal = pal;
8051 44 memcpy(sys_pal,pal,sizeof(pal));
8052 44 }
8053
8054 void system_pal2()
8055 {
8056 is_sys_pal = true;
8057 static PALETTE RAMpal2;
8058 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8059
8060 /* Windows 2000 colors
8061 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8062 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8063 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8064 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8065 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8066 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8067 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8068 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8069
8070 byte palrstart= 10*63/255, palrend=166*63/255,
8071 palgstart= 36*63/255, palgend=202*63/255,
8072 palbstart=106*63/255, palbend=240*63/255,
8073 paldivs=7;
8074 for(int32_t i=0; i<paldivs; i++)
8075 {
8076 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8077 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8078 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8079 }
8080 */
8081
8082 /* Windows 98 colors
8083 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8084 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8085 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8086 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8087 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8088 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8089 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8090 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8091
8092 byte palrstart= 0*63/255, palrend=166*63/255,
8093 palgstart= 0*63/255, palgend=202*63/255,
8094 palbstart=128*63/255, palbend=240*63/255,
8095 paldivs=7;
8096 for(int32_t i=0; i<paldivs; i++)
8097 {
8098 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8099 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8100 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8101 }
8102 */
8103
8104 /* Windows 99 colors
8105 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8106 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8107 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8108 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8109 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8110 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8111 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8112 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8113 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8114
8115 byte palrstart= 0*63/255, palrend=166*63/255,
8116 palgstart= 0*63/255, palgend=202*63/255,
8117
8118 palbstart=128*63/255, palbend=240*63/255,
8119 paldivs=6;
8120 for(int32_t i=0; i<paldivs; i++)
8121 {
8122 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8123 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8124 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8125 }
8126 */
8127
8128
8129
8130 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8131 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8132 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8133 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8134 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8135 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8136 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8137 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8138 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8139
8140 byte palrstart= 0*63/255, palrend=166*63/255,
8141 palgstart= 0*63/255, palgend=202*63/255,
8142 palbstart=128*63/255, palbend=240*63/255,
8143 paldivs=6;
8144
8145 for(int32_t i=0; i<paldivs; i++)
8146 {
8147 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8148 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8149 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8150 }
8151
8152 gui_bg_color=jwin_pal[jcBOX];
8153 gui_fg_color=jwin_pal[jcBOXFG];
8154
8155 jwin_set_colors(jwin_pal);
8156
8157
8158 // set up the new palette
8159 for(int32_t i=128; i<192; i++)
8160 {
8161 RAMpal2[i].r = i-128;
8162 RAMpal2[i].g = i-128;
8163 RAMpal2[i].b = i-128;
8164 }
8165
8166 /*
8167 for(int32_t i=0; i<64; i++)
8168 {
8169 RAMpal2[128+i] = _RGB(i,i,i)1));
8170 }
8171 */
8172
8173 /*
8174
8175 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8176 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8177 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8178 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8179 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8180 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8181 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8182
8183 gui_fg_color=vc(14);
8184 gui_bg_color=vc(1);
8185
8186 jwin_set_colors(jwin_pal);
8187 */
8188
8189 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8190
8191 // set up the colors for the vertical screen gradient
8192 for(int32_t i=0; i<256; i+=2)
8193 {
8194 int32_t v = (i>>3)+2;
8195 int32_t c = (i>>3)+192;
8196 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8197
8198 /*
8199 if(i<240)
8200 {
8201 _allegro_hline(tmp_scr,0,i,319,c);
8202 _allegro_hline(tmp_scr,0,i+1,319,c);
8203 }
8204 */
8205 }
8206
8207 // hw_palette = &RAMpal;
8208 // update_hw_pal = true;
8209
8210 for(int32_t i=0; i<240; ++i)
8211 {
8212 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8213 }
8214
8215 /*
8216 byte palrstart= 10*63/255, palrend=166*63/255,
8217 palgstart= 36*63/255, palgend=202*63/255,
8218 palbstart=106*63/255, palbend=240*63/255,
8219 paldivs=32;
8220 for(int32_t i=0; i<paldivs; i++)
8221 {
8222 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8223 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8224 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8225 }
8226 */
8227 BITMAP *panorama = create_bitmap_ex(8,256,224);
8228 int32_t ts_height, ts_start;
8229
8230 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8231 {
8232 clear_to_color(panorama,0);
8233 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8234 ts_height=224-passive_subscreen_height;
8235 ts_start=28;
8236 }
8237 else
8238 {
8239 blit(framebuf,panorama,0,0,0,0,256,224);
8240 ts_height=224;
8241 ts_start=0;
8242 }
8243
8244 // gray scale the current frame
8245 for(int32_t y=0; y<ts_height; y++)
8246 {
8247 for(int32_t x=0; x<256; x++)
8248 {
8249 int32_t c = panorama->line[y+ts_start][x];
8250 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8251 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8252 }
8253 }
8254
8255 destroy_bitmap(panorama);
8256
8257 // display everything
8258 vsync();
8259 hw_palette = &RAMpal2;
8260 update_hw_pal = true;
8261
8262 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8263
8264 // sys_pal = pal;
8265 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8266 }
8267
8268 static uint32_t entered_sys_pal = 0;
8269 13 void enter_sys_pal()
8270 {
8271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(is_sys_pal)
8272 {
8273 if(entered_sys_pal)
8274 ++entered_sys_pal;
8275 return;
8276 }
8277 13 system_pal();
8278 13 ++entered_sys_pal;
8279 13 }
8280 13 void exit_sys_pal()
8281 {
8282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(entered_sys_pal)
8283 {
8284
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!--entered_sys_pal)
8285 {
8286 13 game_pal();
8287 13 }
8288 13 }
8289 13 }
8290
8291 void switch_out_callback()
8292 {
8293 if (pause_in_background)
8294 {
8295 callback_switchin = 3;
8296 return;
8297 }
8298
8299 #ifdef _WIN32
8300 if(midi_patch_fix==0 || currmidi==-1)
8301 return;
8302
8303
8304 paused_midi_pos = midi_pos;
8305 zc_stop_midi();
8306 midi_paused=true;
8307 midi_suspended = midissuspHALTED;
8308 #endif
8309 }
8310
8311 void switch_in_callback()
8312 {
8313 if(pause_in_background)
8314 {
8315 return;
8316 }
8317
8318 #ifdef _WIN32
8319 if(midi_patch_fix==0 || currmidi==-1)
8320 return;
8321
8322 else
8323 {
8324 callback_switchin = 1;
8325 midi_suspended = midissuspRESUME;
8326 }
8327 #endif
8328 }
8329
8330 278 void game_pal()
8331 {
8332 278 is_sys_pal = false;
8333 278 entered_sys_pal = 0;
8334 278 clear_to_color(screen,BLACK);
8335 278 hw_palette = &RAMpal;
8336 278 update_hw_pal = true;
8337 278 }
8338
8339 static char bar_str[] = "";
8340
8341 13 void music_pause()
8342 {
8343 //al_pause_duh(tmplayer);
8344 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
8345 13 zc_midi_pause();
8346 13 midi_paused=true;
8347 13 }
8348
8349 void music_resume()
8350 {
8351 //al_resume_duh(tmplayer);
8352 zcmusic_pause(zcmusic, ZCM_RESUME);
8353 zc_midi_resume();
8354 midi_paused=false;
8355 }
8356
8357 5903 void music_stop()
8358 {
8359 //al_stop_duh(tmplayer);
8360 //unload_duh(tmusic);
8361 //tmusic=NULL;
8362 //tmplayer=NULL;
8363 5903 zcmusic_stop(zcmusic);
8364 5903 zcmusic_unload_file(zcmusic);
8365 5903 zc_stop_midi();
8366 5903 midi_paused=false;
8367 5903 currmidi=-1;
8368 5903 }
8369
8370 void System()
8371 {
8372 mouse_down=gui_mouse_b();
8373 music_pause();
8374 pause_all_sfx();
8375 MenuOpen = true;
8376 system_pal();
8377 // FONT *oldfont=font;
8378 // font=tfont;
8379
8380 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8381 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8382
8383 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8384 #if DEVLEVEL > 1
8385 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8386 #endif
8387 game_menu[3].flags =
8388 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8389 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8390 clear_keybuf();
8391 sys_mouse();
8392
8393 DIALOG_PLAYER *p;
8394
8395 clear_bitmap(menu_bmp);
8396 oldscreen = screen;
8397 screen = menu_bmp;
8398
8399 p = init_dialog(system_dlg,-1);
8400
8401 // drop the menu on startup if menu button pressed
8402 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8403 simulate_keypress(KEY_G << 8);
8404
8405 do
8406 {
8407 if(close_button_quit)
8408 {
8409 close_button_quit = false;
8410 f_Quit(qEXIT);
8411 if(Quit) break;
8412 }
8413 rest(17);
8414
8415 if(mouse_down && !gui_mouse_b())
8416 mouse_down=0;
8417
8418 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8419 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8420 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8421
8422 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8423 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8424 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8425 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8426 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8427 settings_menu[10].flags = NESquit?D_SELECTED:0;
8428 settings_menu[11].flags = volkeys?D_SELECTED:0;
8429
8430 window_menu[0].flags = DragAspect?D_SELECTED:0;
8431 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8432 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8433 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8434 window_menu[4].flags = stretchGame?D_SELECTED:0;
8435
8436 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8437 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8438
8439 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8440 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8441 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8442
8443 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8444 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8445 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8446 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8447
8448 bool nocheat = (replay_is_replaying() || !Playing
8449 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8450 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8451 cheat_menu[0].flags = 0;
8452 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8453 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8454 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8455 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8456 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8457 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8458 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8459 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8460 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8461
8462 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8463 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8464 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8465 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8466 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8467 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8468 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8469 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8470 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8471 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8472 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8473 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8474 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8475 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8476 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8477
8478 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8479 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8480
8481 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8482 (char *)"Disable recording new saves" :
8483 (char *)"Enable recording new saves";
8484 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8485 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8486 (char *)"Stop recording" :
8487 (char *)"Stop replaying";
8488 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8489 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8490 (char *)"Disable snapshot all frames" :
8491 (char *)"Enable snapshot all frames";
8492
8493 reset_snapshot_format_menu();
8494 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8495
8496 if(debug_enabled)
8497 {
8498 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8499 }
8500
8501 if(gui_mouse_b() && !mouse_down)
8502 break;
8503
8504 // press menu to drop the menu
8505 if(rMbtn())
8506 simulate_keypress(KEY_G << 8);
8507
8508 if(input_idle(true) > after_time())
8509 // run Screeen Saver
8510 {
8511 // Screen saver enabled for now.
8512 clear_keybuf();
8513 Matrix(ss_speed, ss_density, 0);
8514 system_pal();
8515 broadcast_dialog_message(MSG_DRAW, 0);
8516 }
8517
8518 update_hw_screen();
8519 }
8520 while(update_dialog(p));
8521
8522 screen = oldscreen;
8523
8524 // font=oldfont;
8525 mouse_down=gui_mouse_b();
8526 shutdown_dialog(p);
8527 game_mouse();
8528 MenuOpen = false;
8529 if(Quit)
8530 {
8531 kill_sfx();
8532 music_stop();
8533 update_hw_screen();
8534 }
8535 else
8536 {
8537 game_pal();
8538 music_resume();
8539 resume_all_sfx();
8540
8541 if(rc)
8542 ringcolor(false);
8543 }
8544
8545 eat_buttons();
8546
8547 rc=false;
8548 clear_keybuf();
8549 // text_mode(0);
8550 }
8551
8552 31 void fix_dialogs()
8553 {
8554 31 jwin_center_dialog(about_dlg);
8555 31 jwin_center_dialog(gamepad_dlg);
8556 31 jwin_center_dialog(credits_dlg);
8557 31 jwin_center_dialog(gamemode_dlg);
8558 31 jwin_center_dialog(getnum_dlg);
8559 31 jwin_center_dialog(goto_dlg);
8560 31 jwin_center_dialog(keyboard_control_dlg);
8561 31 jwin_center_dialog(midi_dlg);
8562 31 jwin_center_dialog(quest_dlg);
8563 31 jwin_center_dialog(scrsaver_dlg);
8564 31 jwin_center_dialog(sound_dlg);
8565 31 jwin_center_dialog(triforce_dlg);
8566
8567 // digi_dp[1] += scrx;
8568 // digi_dp[2] += scry;
8569 // midi_dp[1] += scrx;
8570 // midi_dp[2] += scry;
8571 // pan_dp[1] += scrx;
8572 // pan_dp[2] += scry;
8573 // emus_dp[1] += scrx;
8574 // emus_dp[2] += scry;
8575 // buf_dp[1] += scrx;
8576 // buf_dp[2] += scry;
8577 // sfx_dp[1] += scrx;
8578 // sfx_dp[2] += scry;
8579 31 }
8580
8581 /*****************************/
8582 /**** Custom Sound System ****/
8583 /*****************************/
8584
8585 2611 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8586 {
8587
3/4
✓ Branch 0 taken 2353 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2611 times.
✗ Branch 3 not taken.
2611 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8588 }
8589
8590 // Run an NSF, or a MIDI if the NSF is missing somehow.
8591 93 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8592 {
8593 93 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8594
8595 // Found it
8596
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 35 times.
93 if(newzcmusic!=NULL)
8597 {
8598 58 zcmusic_stop(zcmusic);
8599 58 zcmusic_unload_file(zcmusic);
8600 58 zc_stop_midi();
8601
8602 58 zcmusic=newzcmusic;
8603 58 zcmusic_play(zcmusic, emusic_volume);
8604
8605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(track>0)
8606 58 zcmusic_change_track(zcmusic,track);
8607
8608 58 return true;
8609 }
8610
8611 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8612
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8613 jukebox(midi);
8614
8615 35 return false;
8616 93 }
8617
8618 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8619 {
8620 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8621 // Found it
8622 if(newzcmusic!=NULL)
8623 {
8624 zcmusic_stop(zcmusic);
8625 zcmusic_unload_file(zcmusic);
8626 zc_stop_midi();
8627
8628 zcmusic=newzcmusic;
8629 zcmusic_play(zcmusic, emusic_volume);
8630
8631 if(track>0)
8632 zcmusic_change_track(zcmusic,track);
8633
8634 return true;
8635 }
8636
8637 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8638 else if(midi>-1000)
8639 jukebox(midi);
8640
8641 return false;
8642 }
8643
8644 int32_t get_zcmusicpos()
8645 {
8646 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8647 return debugtracething;
8648 return 0;
8649 }
8650
8651 void set_zcmusicpos(int32_t position)
8652 {
8653 zcmusic_set_curpos(zcmusic, position);
8654 }
8655
8656 void set_zcmusicspeed(int32_t speed)
8657 {
8658 int32_t newspeed = vbound(speed, 0, 10000);
8659 zcmusic_set_speed(zcmusic, newspeed);
8660 }
8661
8662 1290 void jukebox(int32_t index,int32_t loop)
8663 {
8664 1290 music_stop();
8665
8666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(index<0) index=MAXMIDIS-1;
8667
8668
1/2
✓ Branch 0 taken 1290 times.
✗ Branch 1 not taken.
1290 if(index>=MAXMIDIS) index=0;
8669
8670 1290 music_stop();
8671
8672 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8673 // stuck notes when a song stops. This fixes it.
8674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(strcmp(midi_driver->name, "DIGMID")==0)
8675 zc_set_volume(0, 0);
8676
8677 1290 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8678 1290 zc_play_midi((MIDI*)tunes[index].data,loop);
8679
8680
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 380 times.
1290 if(tunes[index].start>0)
8681 380 zc_midi_seek(tunes[index].start);
8682
8683 1290 midi_loop_start = tunes[index].loop_start;
8684 1290 midi_loop_end = tunes[index].loop_end;
8685
8686 1290 currmidi=index;
8687 1290 master_volume(digi_volume,midi_volume);
8688 1290 midi_paused=false;
8689 1290 }
8690
8691 10507 void jukebox(int32_t index)
8692 {
8693
1/2
✓ Branch 0 taken 10507 times.
✗ Branch 1 not taken.
10507 if(index<0) index=MAXMIDIS-1;
8694
8695
1/2
✓ Branch 0 taken 10507 times.
✗ Branch 1 not taken.
10507 if(index>=MAXMIDIS) index=0;
8696
8697 // do nothing if it's already playing
8698
3/4
✓ Branch 0 taken 9217 times.
✓ Branch 1 taken 1290 times.
✓ Branch 2 taken 9217 times.
✗ Branch 3 not taken.
10507 if(index==currmidi && midi_pos>=0)
8699 {
8700 9217 midi_paused=false;
8701 9217 return;
8702 }
8703
8704 1290 jukebox(index,tunes[index].loop);
8705 10507 }
8706
8707 11742 void play_DmapMusic()
8708 {
8709 static char tfile[2048];
8710 static int32_t ttrack=0;
8711 11742 bool domidi=false;
8712
8713
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 10412 times.
11742 if(DMaps[currdmap].tmusic[0]!=0)
8714 {
8715
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8716
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8717
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8718 {
8719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8720 {
8721 zcmusic_stop(zcmusic);
8722 zcmusic_unload_file(zcmusic);
8723 zcmusic = NULL;
8724 }
8725
8726 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8727
8728
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8729 {
8730 86 zc_stop_midi();
8731 86 strcpy(tfile,DMaps[currdmap].tmusic);
8732 86 zcmusic_play(zcmusic, emusic_volume);
8733 86 int32_t temptracks=0;
8734 86 temptracks=zcmusic_get_tracks(zcmusic);
8735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8736 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8737 86 zcmusic_change_track(zcmusic,ttrack);
8738 86 }
8739 else
8740 {
8741 859 tfile[0] = 0;
8742 859 domidi=true;
8743 }
8744 945 }
8745 1330 }
8746 else
8747 {
8748 10412 domidi=true;
8749 }
8750
8751
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 11271 times.
11742 if(domidi)
8752 {
8753 11271 int32_t m=DMaps[currdmap].midi;
8754
8755
3/4
✓ Branch 0 taken 11139 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
11271 switch(m)
8756 {
8757 case 1:
8758 105 jukebox(ZC_MIDI_OVERWORLD);
8759 105 break;
8760
8761 case 2:
8762 27 jukebox(ZC_MIDI_DUNGEON);
8763 27 break;
8764
8765 case 3:
8766 jukebox(ZC_MIDI_LEVEL9);
8767 break;
8768
8769 default:
8770
3/4
✓ Branch 0 taken 10226 times.
✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10226 times.
11139 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8771 10226 jukebox(m+MIDIOFFSET_DMAP);
8772 else
8773 913 music_stop();
8774 11139 }
8775 11271 }
8776 11742 }
8777
8778 11779 void playLevelMusic()
8779 {
8780 11779 int32_t m=tmpscr->screen_midi;
8781
8782
3/6
✓ Branch 0 taken 11726 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
11779 switch(m)
8783 {
8784 case -2:
8785 12 music_stop();
8786 12 break;
8787
8788 case -1:
8789 11726 play_DmapMusic();
8790 11726 break;
8791
8792 case 1:
8793 jukebox(ZC_MIDI_OVERWORLD);
8794 break;
8795
8796 case 2:
8797 jukebox(ZC_MIDI_DUNGEON);
8798 break;
8799
8800 case 3:
8801 jukebox(ZC_MIDI_LEVEL9);
8802 break;
8803
8804 default:
8805
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8806 41 jukebox(m+MIDIOFFSET_MAPSCR);
8807 else
8808 music_stop();
8809 41 }
8810 11779 }
8811
8812 1321 void master_volume(int32_t dv,int32_t mv)
8813 {
8814
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1321 times.
✓ Branch 2 taken 1321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1321 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1321 times.
✗ Branch 7 not taken.
1321 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8815
8816
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1321 times.
✓ Branch 2 taken 1321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1321 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1321 times.
✗ Branch 7 not taken.
1321 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8817
8818
6/6
✓ Branch 0 taken 1286 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 1319 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1284 times.
✓ Branch 5 taken 35 times.
1321 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8819 1321 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8820 1321 }
8821
8822 /*****************/
8823 /***** SFX *****/
8824 /*****************/
8825
8826 // array of voices, one for each sfx sample in the data file
8827 // 0+ = voice #
8828 // -1 = voice not allocated
8829 31 void Z_init_sound()
8830 {
8831
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
7967 for(int32_t i=0; i<WAV_COUNT; i++)
8832 7936 sfx_voice[i]=-1;
8833
8834
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 31 times.
248 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8835 217 tunes[i].data = (MIDI*)mididata[i].dat;
8836
8837
2/2
✓ Branch 0 taken 7812 times.
✓ Branch 1 taken 31 times.
7843 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8838 7812 tunes[ZC_MIDI_COUNT+j].data=NULL;
8839
8840 31 master_volume(digi_volume,midi_volume);
8841 31 }
8842
8843 // returns number of voices currently allocated
8844 int32_t sfx_count()
8845 {
8846 int32_t c=0;
8847
8848 for(int32_t i=0; i<WAV_COUNT; i++)
8849 if(sfx_voice[i]!=-1)
8850 ++c;
8851
8852 return c;
8853 }
8854
8855 // clean up finished samples
8856 7475599 void sfx_cleanup()
8857 {
8858
2/2
✓ Branch 0 taken 1913753344 times.
✓ Branch 1 taken 7475599 times.
1921228943 for(int32_t i=0; i<WAV_COUNT; i++)
8859
3/4
✓ Branch 0 taken 609274 times.
✓ Branch 1 taken 1913144070 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 609274 times.
1914362618 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8860 {
8861 609274 deallocate_voice(sfx_voice[i]);
8862 609274 sfx_voice[i]=-1;
8863 609274 }
8864 7475599 }
8865
8866 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8867 // if a voice is already allocated (and/or playing), then it just returns true
8868 // Returns true: voice is allocated
8869 // false: unsuccessful
8870 939514 bool sfx_init(int32_t index)
8871 {
8872 // check index
8873
3/4
✓ Branch 0 taken 676840 times.
✓ Branch 1 taken 262674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 676840 times.
939514 if(index<=0 || index>=WAV_COUNT)
8874 262674 return false;
8875
8876
2/2
✓ Branch 0 taken 67541 times.
✓ Branch 1 taken 609299 times.
676840 if(sfx_voice[index]==-1)
8877 {
8878
2/2
✓ Branch 0 taken 163578 times.
✓ Branch 1 taken 445721 times.
609299 if(sfxdat)
8879 {
8880
1/2
✓ Branch 0 taken 163578 times.
✗ Branch 1 not taken.
163578 if(index<Z35)
8881 {
8882 163578 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8883 163578 }
8884 else
8885 {
8886 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8887 }
8888 163578 }
8889 else
8890 {
8891 445721 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8892 }
8893
8894 609299 voice_set_volume(sfx_voice[index], sfx_volume);
8895 609299 }
8896
8897 676840 return sfx_voice[index] != -1;
8898 939514 }
8899
8900 // plays an sfx sample
8901 801152 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8902 {
8903
2/2
✓ Branch 0 taken 608287 times.
✓ Branch 1 taken 192865 times.
801152 if(!sfx_init(index))
8904 192865 return;
8905
8906 608287 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8907 608287 voice_set_pan(sfx_voice[index],pan);
8908
8909 608287 int32_t pos = voice_get_position(sfx_voice[index]);
8910
8911
2/2
✓ Branch 0 taken 288965 times.
✓ Branch 1 taken 319322 times.
608287 if(restart) voice_set_position(sfx_voice[index],0);
8912
8913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 608287 times.
608287 if(pos<=0)
8914 608287 voice_start(sfx_voice[index]);
8915
8916
3/4
✓ Branch 0 taken 319322 times.
✓ Branch 1 taken 288965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 319322 times.
608287 if (restart && replay_is_debug())
8917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319322 times.
319322 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8918 801152 }
8919
8920 // true if sfx is allocated
8921 34070 bool sfx_allocated(int32_t index)
8922 {
8923
3/4
✓ Branch 0 taken 9405 times.
✓ Branch 1 taken 24665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9405 times.
34070 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8924 }
8925
8926 // start it (in loop mode) if it's not already playing,
8927 // otherwise adjust it to play in loop mode -DD
8928 138362 void cont_sfx(int32_t index)
8929 {
8930
2/2
✓ Branch 0 taken 69809 times.
✓ Branch 1 taken 68553 times.
138362 if(!sfx_init(index))
8931 {
8932 69809 return;
8933 }
8934
8935
1/2
✓ Branch 0 taken 68553 times.
✗ Branch 1 not taken.
68553 if(voice_get_position(sfx_voice[index])<=0)
8936 {
8937 68553 voice_set_position(sfx_voice[index],0);
8938 68553 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8939 68553 voice_start(sfx_voice[index]);
8940 68553 }
8941 else
8942 {
8943 adjust_sfx(index, 128, true);
8944 }
8945 138362 }
8946
8947 // adjust parameters while playing
8948 3829 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8949 {
8950
5/6
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 1659 times.
✓ Branch 2 taken 2170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2156 times.
3829 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8951 3815 return;
8952
8953 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8954 14 voice_set_pan(sfx_voice[index],pan);
8955 3829 }
8956
8957 // pauses a voice
8958 1593 void pause_sfx(int32_t index)
8959 {
8960
3/6
✓ Branch 0 taken 1593 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1593 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1593 times.
1593 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8961 voice_stop(sfx_voice[index]);
8962 1593 }
8963
8964 // resumes a voice
8965 688 void resume_sfx(int32_t index)
8966 {
8967
3/6
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 688 times.
688 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8968 voice_start(sfx_voice[index]);
8969 688 }
8970
8971 // pauses all active voices
8972 295 void pause_all_sfx()
8973 {
8974
2/2
✓ Branch 0 taken 75520 times.
✓ Branch 1 taken 295 times.
75815 for(int32_t i=0; i<WAV_COUNT; i++)
8975
2/2
✓ Branch 0 taken 75519 times.
✓ Branch 1 taken 1 times.
75521 if(sfx_voice[i]!=-1)
8976 1 voice_stop(sfx_voice[i]);
8977 295 }
8978
8979 // resumes all paused voices
8980 282 void resume_all_sfx()
8981 {
8982
2/2
✓ Branch 0 taken 72192 times.
✓ Branch 1 taken 282 times.
72474 for(int32_t i=0; i<WAV_COUNT; i++)
8983
1/2
✓ Branch 0 taken 72192 times.
✗ Branch 1 not taken.
72192 if(sfx_voice[i]!=-1)
8984 voice_start(sfx_voice[i]);
8985 282 }
8986
8987 // stops an sfx and deallocates the voice
8988 6023510 void stop_sfx(int32_t index)
8989 {
8990
3/4
✓ Branch 0 taken 5267410 times.
✓ Branch 1 taken 756100 times.
✓ Branch 2 taken 5267410 times.
✗ Branch 3 not taken.
6023510 if(index<=0 || index>=WAV_COUNT)
8991 756100 return;
8992
8993
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5267397 times.
5267410 if(sfx_voice[index]!=-1)
8994 {
8995 13 deallocate_voice(sfx_voice[index]);
8996 13 sfx_voice[index]=-1;
8997 13 }
8998 6023510 }
8999
9000 // Stops SFX played by Hero's item of the given family
9001 129331 void stop_item_sfx(int32_t family)
9002 {
9003 129331 int32_t id=current_item_id(family);
9004
9005
2/2
✓ Branch 0 taken 128931 times.
✓ Branch 1 taken 400 times.
129331 if(id<0)
9006 128931 return;
9007
9008 400 stop_sfx(itemsbuf[id].usesound);
9009 129331 }
9010
9011 2102 void kill_sfx()
9012 {
9013
2/2
✓ Branch 0 taken 538112 times.
✓ Branch 1 taken 2102 times.
540214 for(int32_t i=0; i<WAV_COUNT; i++)
9014
2/2
✓ Branch 0 taken 538100 times.
✓ Branch 1 taken 12 times.
538124 if(sfx_voice[i]!=-1)
9015 {
9016 12 deallocate_voice(sfx_voice[i]);
9017 12 sfx_voice[i]=-1;
9018 12 }
9019 2102 }
9020
9021 561292 int32_t pan(int32_t x)
9022 {
9023
1/4
✓ Branch 0 taken 561292 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
561292 switch(pan_style)
9024 {
9025 case 0:
9026 return 128;
9027
9028 case 1:
9029 561292 return vbound((x>>1)+68,0,255);
9030
9031 case 2:
9032 return vbound(((x*3)>>2)+36,0,255);
9033 }
9034
9035 return vbound(x,0,255);
9036 561292 }
9037
9038 /*******************************/
9039 /******* Input Handlers ********/
9040 /*******************************/
9041
9042 19678108 bool joybtn(int32_t b)
9043 {
9044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19678108 times.
19678108 if(b == 0)
9045 return false;
9046
9047 19678108 return joy[joystick_index].button[b-1].b !=0;
9048 19678108 }
9049
9050 const char* joybtn_name(int32_t b)
9051 {
9052 if(b == 0)
9053 return "";
9054
9055 return joy[joystick_index].button[b-1].name;
9056 }
9057
9058 int32_t next_press_key();
9059
9060 int32_t next_press_btn()
9061 {
9062 clear_keybuf();
9063 /*bool b[joy[joystick_index].num_buttons+1];
9064
9065 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9066 b[i]=joybtn(i);*/
9067
9068 //first, we need to wait until they're pressing no buttons
9069 for(;;)
9070 {
9071 if(keypressed())
9072 {
9073 switch(readkey()>>8)
9074 {
9075 case KEY_ESC:
9076 return -1;
9077
9078 case KEY_SPACE:
9079 return 0;
9080 }
9081 }
9082
9083 poll_joystick();
9084 bool done = true;
9085
9086 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9087 {
9088 if(joybtn(i)) done = false;
9089 }
9090
9091 if(done) break;
9092 rest(1);
9093 }
9094
9095 //now, we need to wait for them to press any button
9096 for(;;)
9097 {
9098 if(keypressed())
9099 {
9100 switch(readkey()>>8)
9101 {
9102 case KEY_ESC:
9103 return -1;
9104
9105 case KEY_SPACE:
9106 return 0;
9107 }
9108 }
9109
9110 poll_joystick();
9111
9112 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9113 {
9114 if(joybtn(i)) return i;
9115 }
9116 rest(1);
9117 }
9118 }
9119
9120 155706234 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9121 {
9122
2/2
✓ Branch 0 taken 150246799 times.
✓ Branch 1 taken 5459435 times.
155706234 bool ret = btn && !flag;
9123
2/2
✓ Branch 0 taken 132905621 times.
✓ Branch 1 taken 22800613 times.
155706234 flag = rawbtn ? *rawbtn : btn;
9124
9125 155706234 return ret;
9126 }
9127 1431671 static bool rButtonPeek(bool btn, bool flag)
9128 {
9129
2/2
✓ Branch 0 taken 1339943 times.
✓ Branch 1 taken 91728 times.
1431671 if(!btn)
9130 {
9131 1339943 return false;
9132 }
9133
2/2
✓ Branch 0 taken 15558 times.
✓ Branch 1 taken 76170 times.
91728 else if(!flag)
9134 {
9135 15558 return true;
9136 }
9137
9138 76170 return false;
9139 1431671 }
9140
9141 // Updated only by keyboard/gamepad.
9142 // If in replay mode, this is set directly by the replay system.
9143 // This should never be read from directly - use control_state instead.
9144 bool raw_control_state[ZC_CONTROL_STATES];
9145
9146 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9147 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9148 // lasts until the next call to load_control_state.
9149 bool control_state[ZC_CONTROL_STATES];
9150 bool disable_control[ZC_CONTROL_STATES];
9151 bool drunk_toggle_state[11];
9152 bool disabledKeys[127];
9153 bool KeyInput[127];
9154 bool KeyPress[127];
9155
9156 bool key_current_frame[127];
9157 bool key_previous_frame[127];
9158
9159 static bool key_system[127];
9160 static bool key_system_previous[127];
9161 static bool key_system_press[127];
9162
9163 bool button_press[ZC_CONTROL_STATES];
9164 bool button_hold[ZC_CONTROL_STATES];
9165
9166 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9167 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9168 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9169 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9170 #define STICK_PRECISION 56 //define your own sensitivity
9171
9172 6290002 void load_control_state()
9173 {
9174 6290002 load_control_called_this_frame = true;
9175
9176
4/4
✓ Branch 0 taken 3418801 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 856645 times.
✓ Branch 3 taken 2562156 times.
6290002 if (replay_get_version() >= 8 && replay_get_version() < 11)
9177 {
9178
2/2
✓ Branch 0 taken 46118808 times.
✓ Branch 1 taken 2562156 times.
48680964 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9179 46118808 down_control_states[i] = raw_control_state[i];
9180 2562156 }
9181
9182
1/2
✓ Branch 0 taken 6290002 times.
✗ Branch 1 not taken.
6290002 if (!replay_is_replaying())
9183 {
9184 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9185 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9186 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9187 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9188 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9189 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9190 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9191 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9192 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9193 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9194 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9195 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9196 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9197 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9198
9199 if(num_joysticks != 0)
9200 {
9201 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9202 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9203 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9204 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9205 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9206 }
9207 else
9208 {
9209 raw_control_state[14] = false;
9210 raw_control_state[15] = false;
9211 raw_control_state[16] = false;
9212 raw_control_state[17] = false;
9213 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9214 }
9215 bool did_bad_cutscene_btn = false;
9216 for(int q = 0; q < 18; ++q)
9217 if(raw_control_state[q] && !active_cutscene.can_button(q))
9218 {
9219 raw_control_state[q] = false;
9220 did_bad_cutscene_btn = true;
9221 }
9222 if(did_bad_cutscene_btn)
9223 active_cutscene.error();
9224 }
9225
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6289999 times.
6290002 if (replay_is_active())
9226 {
9227
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5274784 times.
6289999 if (replay_get_version() < 3)
9228 1015215 replay_poll();
9229
3/4
✓ Branch 0 taken 5274784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3513409 times.
✓ Branch 3 taken 1761375 times.
5274784 else if (replay_is_replaying() && replay_get_version() < 6)
9230 1761375 replay_peek_input();
9231
5/6
✓ Branch 0 taken 3513409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418801 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 856645 times.
✓ Branch 5 taken 2562156 times.
3513409 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9232 2562156 replay_peek_input();
9233
2/2
✓ Branch 0 taken 5177373 times.
✓ Branch 1 taken 1112626 times.
6289999 if (replay_get_version() == 8)
9234 1112626 update_keys();
9235 6289999 }
9236
9237 // Some test replay files were made before a serious input bug was fixed, so instead
9238 // of re-doing them or tossing them out, just check for that zplay version.
9239
3/4
✓ Branch 0 taken 6289996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6168096 times.
6290002 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9240
2/2
✓ Branch 0 taken 113219928 times.
✓ Branch 1 taken 6289996 times.
119509924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9241 {
9242 113219928 control_state[i] = raw_control_state[i];
9243
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 63732618 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
113219928 if (botched_input && !control_state[i])
9244 47077142 down_control_states[i] = false;
9245 113219928 }
9246
9247 6289996 button_press[0]=rButton(control_state[0],button_hold[0]);
9248 6289996 button_press[1]=rButton(control_state[1],button_hold[1]);
9249 6289996 button_press[2]=rButton(control_state[2],button_hold[2]);
9250 6289996 button_press[3]=rButton(control_state[3],button_hold[3]);
9251 6289996 button_press[4]=rButton(control_state[4],button_hold[4]);
9252 6289996 button_press[5]=rButton(control_state[5],button_hold[5]);
9253 6289996 button_press[6]=rButton(control_state[6],button_hold[6]);
9254 6289996 button_press[7]=rButton(control_state[7],button_hold[7]);
9255 6289996 button_press[8]=rButton(control_state[8],button_hold[8]);
9256 6289996 button_press[9]=rButton(control_state[9],button_hold[9]);
9257 6289996 button_press[10]=rButton(control_state[10],button_hold[10]);
9258 6289996 button_press[11]=rButton(control_state[11],button_hold[11]);
9259 6289996 button_press[12]=rButton(control_state[12],button_hold[12]);
9260 6289996 button_press[13]=rButton(control_state[13],button_hold[13]);
9261 6289996 button_press[14]=rButton(control_state[14],button_hold[14]);
9262 6289996 button_press[15]=rButton(control_state[15],button_hold[15]);
9263 6289996 button_press[16]=rButton(control_state[16],button_hold[16]);
9264 6289996 button_press[17]=rButton(control_state[17],button_hold[17]);
9265 6289996 }
9266
9267 // Returns true if any game key is pressed. This is needed because keypressed()
9268 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9269 32550245 bool zc_key_pressed()
9270 //may also need to use zc_getrawkey
9271 {
9272
7/10
✓ Branch 0 taken 26347362 times.
✓ Branch 1 taken 6202883 times.
✓ Branch 2 taken 6202883 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6202883 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5214399 times.
✓ Branch 7 taken 5214399 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1926522 times.
34476767 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9273
4/6
✓ Branch 0 taken 5214399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5214399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3929624 times.
✓ Branch 5 taken 3929624 times.
5214399 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9274
4/6
✓ Branch 0 taken 3929624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929624 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2520637 times.
✓ Branch 5 taken 2520637 times.
3929624 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9275
4/6
✓ Branch 0 taken 2520637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2520637 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2165807 times.
✓ Branch 5 taken 2165807 times.
2520637 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9276
1/2
✓ Branch 0 taken 2165807 times.
✗ Branch 1 not taken.
2165807 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9277
3/4
✓ Branch 0 taken 2053185 times.
✓ Branch 1 taken 112622 times.
✓ Branch 2 taken 2053185 times.
✗ Branch 3 not taken.
2165807 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9278
3/4
✓ Branch 0 taken 1954768 times.
✓ Branch 1 taken 98417 times.
✓ Branch 2 taken 1954768 times.
✗ Branch 3 not taken.
2053185 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9279
3/4
✓ Branch 0 taken 1941065 times.
✓ Branch 1 taken 13703 times.
✓ Branch 2 taken 1941065 times.
✗ Branch 3 not taken.
1954768 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9280
3/4
✓ Branch 0 taken 1928971 times.
✓ Branch 1 taken 12094 times.
✓ Branch 2 taken 1928971 times.
✗ Branch 3 not taken.
1941065 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9281
3/4
✓ Branch 0 taken 1927380 times.
✓ Branch 1 taken 1591 times.
✓ Branch 2 taken 1927380 times.
✗ Branch 3 not taken.
1928971 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9282
3/4
✓ Branch 0 taken 1927328 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 1927328 times.
✗ Branch 3 not taken.
1927380 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9283
3/4
✓ Branch 0 taken 1926541 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 1926541 times.
✗ Branch 3 not taken.
1927328 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9284
2/4
✓ Branch 0 taken 1926541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1926541 times.
✗ Branch 3 not taken.
1926541 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9285
2/2
✓ Branch 0 taken 1926522 times.
✓ Branch 1 taken 19 times.
1926541 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9286 58284657 return true;
9287
9288 1926522 return false;
9289 7516455 }
9290
9291 124566659 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9292 {
9293 124566659 bool ret = false, drunkstate = false, rawret = false;
9294 124566659 bool* flag = &down_control_states[btn];
9295
2/7
✓ Branch 0 taken 117042313 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7524346 times.
124566659 switch(btn)
9296 {
9297 case btnF12:
9298 ret = zc_getkey(KEY_F12, ignoreDisable);
9299 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9300 eatEntirely = false;
9301 break;
9302 case btnF11:
9303 ret = zc_getkey(KEY_F11, ignoreDisable);
9304 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9305 eatEntirely = false;
9306 break;
9307 case btnF5:
9308 ret = zc_getkey(KEY_F5, ignoreDisable);
9309 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9310 eatEntirely = false;
9311 break;
9312 case btnQ:
9313 ret = zc_getkey(KEY_Q, ignoreDisable);
9314 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9315 eatEntirely = false;
9316 break;
9317 case btnI:
9318 ret = zc_getkey(KEY_I, ignoreDisable);
9319 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9320 eatEntirely = false;
9321 break;
9322 case btnM:
9323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7524346 times.
7524346 if(FFCore.kb_typing_mode) return false;
9324 7524346 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9325 7524346 eatEntirely = false;
9326 7524346 break;
9327 default: //control_state[] index
9328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117042313 times.
117042313 if(FFCore.kb_typing_mode) return false;
9329
5/6
✓ Branch 0 taken 116778278 times.
✓ Branch 1 taken 264035 times.
✓ Branch 2 taken 2132745 times.
✓ Branch 3 taken 114645533 times.
✓ Branch 4 taken 2132745 times.
✗ Branch 5 not taken.
117042313 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9330
2/2
✓ Branch 0 taken 6333597 times.
✓ Branch 1 taken 110708716 times.
117042313 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9331
4/4
✓ Branch 0 taken 105554322 times.
✓ Branch 1 taken 11487991 times.
✓ Branch 2 taken 1481 times.
✓ Branch 3 taken 11486510 times.
128530304 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9332 117042313 rawret = raw_control_state[btn];
9333 117042313 }
9334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124566659 times.
124566659 assert(flag);
9335
2/2
✓ Branch 0 taken 80648682 times.
✓ Branch 1 taken 43917977 times.
124566659 if(press)
9336 {
9337
2/2
✓ Branch 0 taken 1431671 times.
✓ Branch 1 taken 42486306 times.
43917977 if(peek)
9338 1431671 ret = rButtonPeek(ret, *flag);
9339
3/4
✓ Branch 0 taken 42486306 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22800613 times.
✓ Branch 3 taken 19685693 times.
42486306 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9340 22800613 else ret = rButton(ret, *flag, &rawret);
9341 43917977 }
9342
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124566659 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124566659 if(eatEntirely && ret) control_state[btn] = false;
9343
3/4
✓ Branch 0 taken 94314777 times.
✓ Branch 1 taken 30251882 times.
✓ Branch 2 taken 94314777 times.
✗ Branch 3 not taken.
124566659 if(drunk && drunkstate) ret = !ret;
9344 124566659 return ret;
9345 124566659 }
9346
9347 6149953 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9348 {
9349 6149953 byte ret = 0;
9350
2/2
✓ Branch 0 taken 4716213 times.
✓ Branch 1 taken 1433740 times.
6149953 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9351
2/2
✓ Branch 0 taken 6149391 times.
✓ Branch 1 taken 562 times.
6149953 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9352
2/2
✓ Branch 0 taken 6149516 times.
✓ Branch 1 taken 437 times.
6149953 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9353
2/2
✓ Branch 0 taken 6149516 times.
✓ Branch 1 taken 437 times.
6149953 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9354
2/2
✓ Branch 0 taken 6149516 times.
✓ Branch 1 taken 437 times.
6149953 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9355
2/2
✓ Branch 0 taken 6149516 times.
✓ Branch 1 taken 437 times.
6149953 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9356
2/2
✓ Branch 0 taken 6149516 times.
✓ Branch 1 taken 437 times.
6149953 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9357
2/2
✓ Branch 0 taken 6149516 times.
✓ Branch 1 taken 437 times.
6149953 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9358 6149953 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9359 }
9360
9361 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9362 {
9363 1114 return intbtn&vals;
9364 }
9365
9366 1454524 bool Up()
9367 {
9368 1454524 return getInput(btnUp);
9369 }
9370 88419 bool Down()
9371 {
9372 88419 return getInput(btnDown);
9373 }
9374 178524 bool Left()
9375 {
9376 178524 return getInput(btnLeft);
9377 }
9378 198804 bool Right()
9379 {
9380 198804 return getInput(btnRight);
9381 }
9382 99306 bool cAbtn()
9383 {
9384 99306 return getInput(btnA);
9385 }
9386 1318258 bool cBbtn()
9387 {
9388 1318258 return getInput(btnB);
9389 }
9390 bool cSbtn()
9391 {
9392 return getInput(btnS);
9393 }
9394 40856 bool cLbtn()
9395 {
9396 40856 return getInput(btnL);
9397 }
9398 40856 bool cRbtn()
9399 {
9400 40856 return getInput(btnR);
9401 }
9402 bool cPbtn()
9403 {
9404 return getInput(btnP);
9405 }
9406 bool cEx1btn()
9407 {
9408 return getInput(btnEx1);
9409 }
9410 bool cEx2btn()
9411 {
9412 return getInput(btnEx2);
9413 }
9414 bool cEx3btn()
9415 {
9416 return getInput(btnEx3);
9417 }
9418 bool cEx4btn()
9419 {
9420 return getInput(btnEx4);
9421 }
9422 bool AxisUp()
9423 {
9424 return getInput(btnAxisUp);
9425 }
9426 bool AxisDown()
9427 {
9428 return getInput(btnAxisDown);
9429 }
9430 bool AxisLeft()
9431 {
9432 return getInput(btnAxisLeft);
9433 }
9434 bool AxisRight()
9435 {
9436 return getInput(btnAxisRight);
9437 }
9438
9439 bool cMbtn()
9440 {
9441 return getInput(btnM);
9442 }
9443 bool cF12()
9444 {
9445 return getInput(btnF12);
9446 }
9447 bool cF11()
9448 {
9449 return getInput(btnF11);
9450 }
9451 bool cF5()
9452 {
9453 return getInput(btnF5);
9454 }
9455 bool cQ()
9456 {
9457 return getInput(btnQ);
9458 }
9459 bool cI()
9460 {
9461 return getInput(btnI);
9462 }
9463
9464 120114 bool rUp()
9465 {
9466 120114 return getInput(btnUp, true);
9467 }
9468 120025 bool rDown()
9469 {
9470 120025 return getInput(btnDown, true);
9471 }
9472 119973 bool rLeft()
9473 {
9474 119973 return getInput(btnLeft, true);
9475 }
9476 119511 bool rRight()
9477 {
9478 119511 return getInput(btnRight, true);
9479 }
9480 2646 bool rAbtn()
9481 {
9482 2646 return getInput(btnA, true);
9483 }
9484 120893 bool rBbtn()
9485 {
9486 120893 return getInput(btnB, true);
9487 }
9488 6098362 bool rSbtn()
9489 {
9490 6098362 return getInput(btnS, true);
9491 }
9492 7516455 bool rMbtn()
9493 {
9494 7516455 return getInput(btnM, true);
9495 }
9496 119304 bool rLbtn()
9497 {
9498 119304 return getInput(btnL, true);
9499 }
9500 119299 bool rRbtn()
9501 {
9502 119299 return getInput(btnR, true);
9503 }
9504 6017755 bool rPbtn()
9505 {
9506 6017755 return getInput(btnP, true);
9507 }
9508 bool rEx1btn()
9509 {
9510 return getInput(btnEx1, true);
9511 }
9512 bool rEx2btn()
9513 {
9514 return getInput(btnEx2, true);
9515 }
9516 130178 bool rEx3btn()
9517 {
9518 130178 return getInput(btnEx3, true);
9519 }
9520 130178 bool rEx4btn()
9521 {
9522 130178 return getInput(btnEx4, true);
9523 }
9524 bool rAxisUp()
9525 {
9526 return getInput(btnAxisUp, true);
9527 }
9528 bool rAxisDown()
9529 {
9530 return getInput(btnAxisDown, true);
9531 }
9532 bool rAxisLeft()
9533 {
9534 return getInput(btnAxisLeft, true);
9535 }
9536 bool rAxisRight()
9537 {
9538 return getInput(btnAxisRight, true);
9539 }
9540
9541 bool rF11()
9542 {
9543 return getInput(btnF11, true);
9544 }
9545 bool rQ()
9546 {
9547 return getInput(btnQ, true);
9548 }
9549 bool rI()
9550 {
9551 return getInput(btnI, true);
9552 }
9553
9554 15270564 bool DrunkUp()
9555 {
9556 15270564 return getInput(btnUp, false, true);
9557 }
9558 14228612 bool DrunkDown()
9559 {
9560 14228612 return getInput(btnDown, false, true);
9561 }
9562 8964768 bool DrunkLeft()
9563 {
9564 8964768 return getInput(btnLeft, false, true);
9565 }
9566 7776409 bool DrunkRight()
9567 {
9568 7776409 return getInput(btnRight, false, true);
9569 }
9570 6659143 bool DrunkcAbtn()
9571 {
9572 6659143 return getInput(btnA, false, true);
9573 }
9574 6550753 bool DrunkcBbtn()
9575 {
9576 6550753 return getInput(btnB, false, true);
9577 }
9578 5976575 bool DrunkcEx1btn()
9579 {
9580 5976575 return getInput(btnEx1, false, true);
9581 }
9582 5976595 bool DrunkcEx2btn()
9583 {
9584 5976595 return getInput(btnEx2, false, true);
9585 }
9586 bool DrunkcSbtn()
9587 {
9588 return getInput(btnS, false, true);
9589 }
9590 bool DrunkcMbtn()
9591 {
9592 return getInput(btnM, false, true);
9593 }
9594 bool DrunkcLbtn()
9595 {
9596 return getInput(btnL, false, true);
9597 }
9598 bool DrunkcRbtn()
9599 {
9600 return getInput(btnR, false, true);
9601 }
9602 bool DrunkcPbtn()
9603 {
9604 return getInput(btnP, false, true);
9605 }
9606
9607 bool DrunkrUp()
9608 {
9609 return getInput(btnUp, true, true);
9610 }
9611 bool DrunkrDown()
9612 {
9613 return getInput(btnDown, true, true);
9614 }
9615 bool DrunkrLeft()
9616 {
9617 return getInput(btnLeft, true, true);
9618 }
9619 bool DrunkrRight()
9620 {
9621 return getInput(btnRight, true, true);
9622 }
9623 5002616 bool DrunkrAbtn()
9624 {
9625 5002616 return getInput(btnA, true, true);
9626 }
9627 5017048 bool DrunkrBbtn()
9628 {
9629 5017048 return getInput(btnB, true, true);
9630 }
9631 71669 bool DrunkrEx1btn()
9632 {
9633 71669 return getInput(btnEx1, true, true);
9634 }
9635 71662 bool DrunkrEx2btn()
9636 {
9637 71662 return getInput(btnEx2, true, true);
9638 }
9639 bool DrunkrEx3btn()
9640 {
9641 return getInput(btnEx3, true, true);
9642 }
9643 bool DrunkrEx4btn()
9644 {
9645 return getInput(btnEx4, true, true);
9646 }
9647 bool DrunkrSbtn()
9648 {
9649 return getInput(btnS, true, true);
9650 }
9651 bool DrunkrMbtn()
9652 {
9653 return getInput(btnM, true, true);
9654 }
9655 5657278 bool DrunkrLbtn()
9656 {
9657 5657278 return getInput(btnL, true, true);
9658 }
9659 5654161 bool DrunkrRbtn()
9660 {
9661 5654161 return getInput(btnR, true, true);
9662 }
9663 bool DrunkrPbtn()
9664 {
9665 return getInput(btnP, true, true);
9666 }
9667
9668 7891 void eat_buttons()
9669 {
9670 7891 getInput(btnA, true, false, true);
9671 7891 getInput(btnB, true, false, true);
9672 7891 getInput(btnS, true, false, true);
9673 7891 getInput(btnM, true, false, true);
9674 7891 getInput(btnL, true, false, true);
9675 7891 getInput(btnR, true, false, true);
9676 7891 getInput(btnP, true, false, true);
9677 7891 getInput(btnEx1, true, false, true);
9678 7891 getInput(btnEx2, true, false, true);
9679 7891 getInput(btnEx3, true, false, true);
9680 7891 getInput(btnEx4, true, false, true);
9681 7891 }
9682
9683 // Is true for the _first frame_ of a key press.
9684 // But! it is possible that a script manually sets the value of KeyPress,
9685 // in which case it will be restored to the "true" value based on `key_current_frame`
9686 // and `key_previous_frame` on the next frame.
9687 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9688 {
9689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9691 {
9692 case KEY_F7:
9693 case KEY_F8:
9694 case KEY_F9:
9695 return KeyPress[k];
9696
9697 default:
9698
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9699 }
9700 13 }
9701
9702 // Is true for _every frame_ a key is held down.
9703 // But! it is possible that a script manually sets the value of KeyInput,
9704 // in which case it will be restored to the "true" value based on `key_current_frame`
9705 // on the next frame.
9706 bool zc_getkey(int32_t k, bool ignoreDisable)
9707 {
9708 if(ignoreDisable) return KeyInput[k];
9709 switch(k)
9710 {
9711 case KEY_F7:
9712 case KEY_F8:
9713 case KEY_F9:
9714 return KeyInput[k];
9715
9716 default:
9717 return KeyInput[k] && !disabledKeys[k];
9718 }
9719 }
9720
9721 // Reads (and then clears) the current frame key state directly.
9722 // Scripts can also modify `key_current_frame`.
9723 140 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9724 {
9725
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 138 times.
140 if(zc_getrawkey(k, ignoreDisable))
9726 {
9727 2 _key[k]=key[k]=key_current_frame[k]=0;
9728 2 return true;
9729 }
9730 138 _key[k]=key[k]=key_current_frame[k]=0;
9731 138 return false;
9732 140 }
9733
9734 // Reads the current frame key state directly.
9735 // Scripts can also modify `key_current_frame`.
9736 50660070 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9737 {
9738
2/2
✓ Branch 0 taken 43143589 times.
✓ Branch 1 taken 7516481 times.
50660070 if(ignoreDisable) return key_current_frame[k];
9739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7516481 times.
7516481 switch(k)
9740 {
9741 case KEY_F7:
9742 case KEY_F8:
9743 case KEY_F9:
9744 return key_current_frame[k];
9745
9746 default:
9747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7516481 times.
7516481 return key_current_frame[k] && !disabledKeys[k];
9748 }
9749 50660070 }
9750
9751 // Only used for a handful of keys, like tilde and Function keys.
9752 // This state is never read within the game.
9753 // It exists so that all keyboard input still functions during replay,
9754 // without inadvertently doing things like toggling throttling if the player
9755 // presses ~
9756 15032981 bool zc_get_system_key(int32_t k)
9757 {
9758 15032981 return key_system[k];
9759 }
9760
9761 // True for the _first_ frame of a key press.
9762 67648095 bool zc_read_system_key(int32_t k)
9763 {
9764 67648095 return key_system_press[k];
9765 }
9766
9767 954589785 bool is_system_key(int32_t k)
9768 {
9769
2/2
✓ Branch 0 taken 886941690 times.
✓ Branch 1 taken 67648095 times.
954589785 switch (k)
9770 {
9771 case KEY_BACKQUOTE:
9772 case KEY_CLOSEBRACE:
9773 case KEY_END:
9774 case KEY_HOME:
9775 case KEY_OPENBRACE:
9776 case KEY_PGDN:
9777 case KEY_PGUP:
9778 case KEY_TAB:
9779 case KEY_TILDE:
9780 67648095 return true;
9781 }
9782 886941690 return is_Fkey(k);
9783 954589785 }
9784
9785 7516455 void update_system_keys()
9786 {
9787
2/2
✓ Branch 0 taken 954589785 times.
✓ Branch 1 taken 7516455 times.
962106240 for (int32_t q = 0; q < 127; ++q)
9788 {
9789
2/2
✓ Branch 0 taken 157845555 times.
✓ Branch 1 taken 796744230 times.
954589785 if (!is_system_key(q))
9790 796744230 continue;
9791
9792 157845555 key_system[q] = key[q];
9793
1/2
✓ Branch 0 taken 157845555 times.
✗ Branch 1 not taken.
157845555 key_system_press[q] = key_system[q] && !key_system_previous[q];
9794 157845555 key_system_previous[q] = key_system[q];
9795 157845555 }
9796 7516455 }
9797
9798 8629081 void update_keys()
9799 {
9800
2/2
✓ Branch 0 taken 1095893287 times.
✓ Branch 1 taken 8629081 times.
1104522368 for (int32_t q = 0; q < 127; ++q)
9801 {
9802 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9803
1/2
✓ Branch 0 taken 1095893287 times.
✗ Branch 1 not taken.
1095893287 if (!replay_is_replaying())
9804 key_current_frame[q] = key[q];
9805
9806
2/2
✓ Branch 0 taken 1087833802 times.
✓ Branch 1 taken 8059485 times.
1095893287 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9807 1095893287 KeyInput[q] = key_current_frame[q];
9808 1095893287 key_previous_frame[q] = key_current_frame[q];
9809 1095893287 }
9810 8629081 }
9811
9812 bool zc_disablekey(int32_t k, bool val)
9813 {
9814 switch(k)
9815 {
9816 case KEY_F7:
9817 case KEY_F8:
9818 case KEY_F9:
9819 return false;
9820
9821 default:
9822 disabledKeys[k] = val;
9823 return true;
9824 }
9825 }
9826
9827 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9828 {
9829 timer=timer;
9830 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9831 }
9832
9833 // these are here so that copy_dialog won't choke when compiling zelda
9834 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9835 {
9836 return D_O_K;
9837 }
9838
9839 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9840 {
9841 return D_O_K;
9842 }
9843
9844 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9845 {
9846 return D_O_K;
9847 }
9848
9849 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9850 {
9851 return D_O_K;
9852 }
9853
9854 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9855 {
9856 return D_O_K;
9857 }
9858
9859 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9860 {
9861 return D_O_K;
9862 }
9863
9864 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9865 {
9866 return D_O_K;
9867 }
9868
9869 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9870 {
9871 return D_O_K;
9872 }
9873
9874 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9875 {
9876 return D_O_K;
9877 }
9878
9879 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9880 {
9881 return D_O_K;
9882 }
9883
9884 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9885 {
9886 return D_O_K;
9887 }
9888
9889 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9890 {
9891 return D_O_K;
9892 }
9893
9894 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9895 {
9896 return D_O_K;
9897 }
9898
9899 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9900 {
9901 return D_O_K;
9902 }
9903
9904 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9905 {
9906 return D_O_K;
9907 }
9908
9909 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9910 {
9911 return D_O_K;
9912 }
9913
9914 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9915 {
9916 return D_O_K;
9917 }
9918
9919 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9920 {
9921 return D_O_K;
9922 }
9923
9924 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9925 {
9926 return D_O_K;
9927 }
9928
9929 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9930 {
9931 return D_O_K;
9932 }
9933
9934 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9935 {
9936 return D_O_K;
9937 }
9938
9939 /*** end of zc_sys.cc ***/
9940
9941